BookmarkSubscribeRSS Feed
puregallus
Calcite | Level 5

Hi all, I'm trying to create a table for each version of a variable in a parent table. Currently I am using the following code:

 

%let TABLE=libref.tablename
%let COLUMN=columnname

proc sql noprint;
select distinct
cat("DATA out_",compress(&COLUMN.,'','kad'),
";set &TABLE.(where=(&COLUMN.='" ,&COLUMN.,
" ')); run;") length=500 into :allsteps separated by ';'
from &TABLE.;
quit;
%macro runSteps;
&allsteps.;
%mend;
%runSteps;

My problem is that I would like to limit to rows of the output tables to a certain number say 5. But I can't quite figure out how to fit obsout into this code. Putting it in the proc sql statement just prevents the looping of of the runSteps macro.

 

Thanks for your help.

1 REPLY 1
gamotte
Rhodochrosite | Level 12

Hello,

 

with call execute in a data step :

 

%let table=sashelp.class;
%let column=age;

data _NULL_;
input age;
call execute(cats('data out_',&column.,'; set &table.; where &column.=',&column.,'; if _N_ le 3; run;'));
cards;
12
13
14
15
16
;
run;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 1 reply
  • 680 views
  • 0 likes
  • 2 in conversation