BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
JJP1
Pyrite | Level 9

Hi ,
Here two datastep statemnets.one is getting the number of records.
another is looping step.so i want to do it using SAS Di transformations.any other option other than user written code please.
i know theoritically i can use loop transfomration but please help more on this how can i achieve this in SAS DI please

data _null_
;
call symputx('tablecount',nobs)
;
set table nobs=nobs
;
stop
;
run
;

%macro macro1
;
%do countloop=1 %to &tablecount
;
data _null_
;
point=&countloop
;
set table point=point
;
call symputx('table_name',cats(libname,'.',memname))
;
stop
;
run
;
1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

My take is that you can't. Insert the sort transformation in each processing chain where it is needed.

You either work with the tools DI Studio gives you, or with code you write. Select which is better for your organisation.

View solution in original post

5 REPLIES 5
Kurt_Bremser
Super User

What are you doing with the macro variable &table_name?

 

My suspicion is that you would be much better off doing this:

%macro macro1(table_name);
/* your processing here */
%mend;

data _null_;
set table;
call execute('%nrstr(%macro1(' !! catx('.',libname,memname) !! '))');
run;
JJP1
Pyrite | Level 9

Thanks @Kurt_Bremser.

&table_name is further being used to sort the data.Would you please help how can i do in using SAS DI please

Kurt_Bremser
Super User

So you want to sort tables? DI Studio has a transformation for that, so use that. And the mechanisms DI Studio provides for repeating tasks.

Since one of the main reasons for using Data Integration is to keep an eye on the sequence of processing (and inheritance of attributes), you need to define the transformation for every single dataset anyway, otherwise DI loses track of the information.

 

You need to accept the fact that GUI applications like DI Studio will always have limited capabilities, as you can't have a wizard for each imaginable programming trick. OTOH, they automate lots of things for you. See Maxim 45.

 

JJP1
Pyrite | Level 9

thank you @Kurt_Bremser  i need to develop job using below code in SAS DI please.
how can i do this.so that i can use sort transformation further on this please

 

%macro macro1
;
%do countloop=1 %to &tablecount
;
data _null_
;
point=&countloop
;
set table point=point
;
call symputx('table_name',cats(libname,'.',memname))
;
stop
;
run
;
data _null_
;
call symputx('tablecount',nobs)
;
set table nobs=nobs
;
stop
;
run
;

Kurt_Bremser
Super User

My take is that you can't. Insert the sort transformation in each processing chain where it is needed.

You either work with the tools DI Studio gives you, or with code you write. Select which is better for your organisation.

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 connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 1437 views
  • 1 like
  • 2 in conversation