In the DATA Step there are several handy ways to print all variables in a generic way to SAS Log. Generic way means that you don't need explicitly list variables.
data class1;
set sashelp.class(obs=3);
put _all_;
run;
Outputs to SAS Log:
73 data class1;
74 set sashelp.class(obs=3);
75 put _all_;
76 run;
Name=Alfred Sex=M Age=14 Height=69 Weight=112.5 _ERROR_=0 _N_=1
Name=Alice Sex=F Age=13 Height=56.5 Weight=84 _ERROR_=0 _N_=2
Name=Barbara Sex=F Age=13 Height=65.3 Weight=98 _ERROR_=0 _N_=3
NOTE: There were 3 observations read from the data set SASHELP.CLASS.
NOTE: The data set WORK.CLASS1 has 3 observations and 5 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
Pretty put -- each variable per line, also a blank line between observations:
data class2;
set sashelp.class(obs=3);
put (_all_) (=/) //;
run;
Outputs:
73 data class2;
74 set sashelp.class(obs=3);
75 put (_all_) (=/) //;
76 run;
Name=Alfred
Sex=M
Age=14
Height=69
Weight=112.5
Name=Alice
Sex=F
Age=13
Height=56.5
Weight=84
Name=Barbara
Sex=F
Age=13
Height=65.3
Weight=98
NOTE: There were 3 observations read from the data set SASHELP.CLASS.
NOTE: The data set WORK.CLASS2 has 3 observations and 5 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
Or subset using arrays:
data class3;
set sashelp.class(obs=3);
array x[*] _char_;
put (x[*]) (=/) //;
run;
73 data class3;
74 set sashelp.class(obs=3);
75 array x[*] _char_;
76 put (x[*]) (=/) //;
77 run;
Name=Alfred
Sex=M
Name=Alice
Sex=F
Name=Barbara
Sex=F
NOTE: There were 3 observations read from the data set SASHELP.CLASS.
NOTE: The data set WORK.CLASS3 has 3 observations and 5 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
Or subset directly using SAS Variable Lists in the PUT statement:
data class4;
set sashelp.baseball(obs=3);
put (n:) (=/) //;
run;
Outputs:
72
73 data class4;
74 set sashelp.baseball(obs=3);
75 put (n:) (=/) //;
76 run;
Name=Allanson, Andy
nAtBat=293
nHits=66
nHome=1
nRuns=30
nRBI=29
nBB=14
nOuts=446
nAssts=33
nError=20
Name=Ashby, Alan
nAtBat=315
nHits=81
nHome=7
nRuns=24
nRBI=38
nBB=39
nOuts=632
nAssts=43
nError=10
Name=Davis, Alan
nAtBat=479
nHits=130
nHome=18
nRuns=66
nRBI=72
nBB=76
nOuts=880
nAssts=82
nError=14
NOTE: There were 3 observations read from the data set SASHELP.BASEBALL.
NOTE: The data set WORK.CLASS4 has 3 observations and 24 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds