Hi all,
Could you please explain what
put (_all_) (+0);
means in the code:
data _null_;
file 'cars_noheader.csv' dsd ;
set sashelp.cars;
put (_all_) (+0);
run;
Thank you!
_all_ is a keyword that gives you all variables present in the PDV.
If you use _all_ without anything else, you get a list including automatic variables in this form:
Make=Acura Model=MDX Type=SUV Origin=Asia DriveTrain=All MSRP=$36,945 Invoice=$33,337 EngineSize=3.5 Cylinders=6 Horsepower=265 MPG_City=17 MPG_Highway=23 Weight=4451 Wheelbase=106 Length=189 _ERROR_=0 _N_=1
If you add the "pseudo-format-specification-with-pointer-control" +0 to all the variables (that's why you need the brackets), you get this:
Acura MDX SUV Asia All $36,945 $33,337 3.5 6 265 17 23 4451 106 189
I got this by applying Maxim 4 and running this code:
data _null_;
set sashelp.cars (obs=1);
put (_all_) (+0);
run;
data _null_;
set sashelp.cars (obs=1);
put _all_;
run;
and inspecting the log.
_all_ is a keyword that gives you all variables present in the PDV.
If you use _all_ without anything else, you get a list including automatic variables in this form:
Make=Acura Model=MDX Type=SUV Origin=Asia DriveTrain=All MSRP=$36,945 Invoice=$33,337 EngineSize=3.5 Cylinders=6 Horsepower=265 MPG_City=17 MPG_Highway=23 Weight=4451 Wheelbase=106 Length=189 _ERROR_=0 _N_=1
If you add the "pseudo-format-specification-with-pointer-control" +0 to all the variables (that's why you need the brackets), you get this:
Acura MDX SUV Asia All $36,945 $33,337 3.5 6 265 17 23 4451 106 189
I got this by applying Maxim 4 and running this code:
data _null_;
set sashelp.cars (obs=1);
put (_all_) (+0);
run;
data _null_;
set sashelp.cars (obs=1);
put _all_;
run;
and inspecting the log.
Thank you for the quick response and the explanations! It is very useful.
I have to say that I could not find a specific reference to the behaviour of _all_ with the modifier in the documentation of PUT. Only the named list output of _all_ without the modifier is documented.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.