DATA Step, Macro, Functions and more

Substituting text in a DOSUBL argument

Reply
Valued Guide
Posts: 505

Substituting text in a DOSUBL argument

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;
Valued Guide
Posts: 505

Re: Substituting text in a DOSUBL argument

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!!
Valued Guide
Posts: 505

Re: Substituting text in a DOSUBL argument

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;
Ask a Question
Discussion stats
  • 2 replies
  • 113 views
  • 0 likes
  • 1 in conversation