sql - SAS Concatenate Multiple Variables to Create Data-Driven Macro Statements -
in order keep process data-driven, i'm trying concatenate multiple variables, separated comma, in order put them in proc sql
list call in multiple macro statements otherwise clutter sas pogram.
take following sample dataset:
data test; input year condition $ qrts $12. sample $; datalines; 2008 mi (1,2,3,4) 2008 mi (1,2,3,4) b ; run;
i'd concatenate these variables together, again separated comma, , add %append
front create huge list of macro statements. new string variable, , macro statements, like:
%append(2008,mi,(1,2,3,4),a);
%append(2008,mi,(1,2,3,4),b);
i've used following compile strings of means , confidence intervals, , imagine similar (i cannot figure out these quotes, commas, , bars data):
ci=compress(put(mean,7.2))||"("||compress(lo)||","|| compress(hi)||")";
once long string variable created, select variable long list through proc sql
statement like:
proc sql; select distinct *new long string variable* into: macrolist separated ' ' test; quit;
ultimately, running ¯olist.
call in hundreds of macro statements append multiple datasets large master dataset. appreciate insight.
answered own question. need:
data test1; set test; string=compress(%nrstr("%append""("||compress(year)||","||compress(condition)||","|| compress(qrts)||","|| compress(sample)||")"),""""); run;
%append
can replaced macro name created, useful.
Comments
Post a Comment