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

Hi all,

 

I recently noticed that, if I want to write a do loop or do a %let statement while on server, it does not work, and it seems that SAS simply ignores the line.

 

* sign on WRDS server;
rsubmit;

%do i = 1980 %to 2000; data a_&i; set ...; run; %end; endrsubmit;

log does not produce any line for that issue, it simply returns an error becasue a_i& is not resolved. The same thing happens if I want to use %let on the server. Is there a way that I can run such macro statements on the server? Or is there anything run with the code?

 

I am familiar with %syslput but somehow cannot figure how to use it with the %do loop. 

 

Thanks a lot,

 

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

@Shayan2012

On top of what @Reeza wrote you need also to be quite carefule how you implement your macro code if combined with rsubmit in regards of timing. If you get it wrong then the macro compiler will resolve your macro stuff before the rsubmit gets executed resulting in the macro stuff being executed on your local machine even though you have it within the rsubmit block in your code.

http://support.sas.com/kb/23/986.html

https://support.sas.com/documentation/cdl/en/connref/69581/HTML/default/viewer.htm#n1wm9969gdtuijn19...

 

View solution in original post

4 REPLIES 4
Reeza
Super User

Macro code needs to generally be embedded in a macro. The code you posted will not work on a desktop either, you need working code in general first. Basically, your errors have nothing to do with being run on a server. 

 

%macro print_loop_useless();
%do i=1 %to 100;

proc print data=sashelp.cars(obs=&i);
run;

%end;
%mend;

%print_loop_useless();

 

 

Shayan2012
Quartz | Level 8
thanks Reeza, I actually had the macro statements, I forgot to put them here while copying and pasting. I do apologize for the inaccuracy.
Patrick
Opal | Level 21

@Shayan2012

On top of what @Reeza wrote you need also to be quite carefule how you implement your macro code if combined with rsubmit in regards of timing. If you get it wrong then the macro compiler will resolve your macro stuff before the rsubmit gets executed resulting in the macro stuff being executed on your local machine even though you have it within the rsubmit block in your code.

http://support.sas.com/kb/23/986.html

https://support.sas.com/documentation/cdl/en/connref/69581/HTML/default/viewer.htm#n1wm9969gdtuijn19...

 

Shayan2012
Quartz | Level 8
Thanks a lot, Patrick. I think my problem was actually the thing that you mentioned, and the documents helped solving the problem.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 4 replies
  • 1248 views
  • 2 likes
  • 3 in conversation