BookmarkSubscribeRSS Feed
rogerjdeangelis
Barite | Level 11
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;
2 REPLIES 2
rogerjdeangelis
Barite | Level 11
Using DOSUBL to Append datasets

https://listserv.uga.edu/cgi-bin/wa?A2=SAS-L;39b80cb6.1702b

Thanks to Quentin McMullen on SAS-L
and
espeecially Muthia Kachirayan for posting the question!!
rogerjdeangelis
Barite | Level 11
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;

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 905 views
  • 0 likes
  • 1 in conversation