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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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