Substituting text in a DOSUBL argument
as a side note- SAS please add the 8pt sasfont, would improve postings. Too much space between lines.
Thanks to Quentin McMullen on SAS-L
https://listserv.uga.edu/cgi-bin/wa?A2=SAS-L;39b80cb6.1702b
Using DOSUBL to Append datasets
HAVE (Two datasets SASHELP.CLASSFIT and SASHELP.CLASS)
Up to 40 obs from SASHELP.CLASSFIT total obs=19
Obs NAME SEX AGE HEIGHT WEIGHT PREDICT ...
1 Joyce F 11 51.3 50.5 56.99
2 Louise F 12 56.3 77 76.48
...
19 Philip M 16 72 150 137.7
Up to 40 obs from SASHELP.CLASS total obs=19
Obs NAME SEX AGE HEIGHT WEIGHT
1 Joyce F 11 51.3 50.5
2 Louise F 12 56.3 77
...
19 Philip M 16 72 150
WANT
===
Up to 40 obs from WANT total obs=38
Obs NAME SEX AGE HEIGHT WEIGHT PREDICT ...
1 Joyce F 11 51.3 50.5 56.99
2 Louise F 12 56.3 77 76.48
37 Thomas M 11 51.3 50.5 .
38 William M 12 56.3 77 .
WORKING CODE
============
rc = dosubl("
proc datasets library = work nolist;
append base = want data = "||ds||" force;
FULL SOLUTION
============
data _null_;
do ds='sashelp.classfit','sashelp.class';
rc = dosubl("
proc datasets library = work nolist;
append base = want data = "||ds||" force;
quit;run;
");
end;
run;quit;
More from SAS-L
I am not sure of this answer, the scoping in DOSUBL is a mystery to me.
It is how SAS has decided to compile DOSUBL?
dosubl concatenates the two strings and and unknown ds variable
"proc datasets library = work nolist; append base = want data = "
ds
" force quit;run;"
The comipler gets the value of DS from the parent?
This surprised me? I had been using call symputx.
The reverse is not true, a new variable in the child is
not available to the parent, but you can delare
commom variable names using the variables address.
* this also works;
%symdel ds;
data _null_;
do ds='sashelp.classfit','sashelp.class';
call symputx('ds',ds);
rc = dosubl("
proc datasets library = work nolist;
append base = want data = &ds force;
quit;run;
%symdel ds;
");
end;
run;quit;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.