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

Hi, I'm doing conditional datasets output within a SAS macro:

 

I already had work.other dataset.

 

%macro m(w);

data dat1 dat2; 

set other; w = &w.;

if diff le &w. then output dat1; 

else output dat2; run;

%mend;

 

It works when I run without the "%macro"

But, when I call the macro by doing "%m(1);", I got an error saying something wrong with the "set": 

 Statement is not valid or it is used out of proper order.

 

Thoughts? Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

As the first line of your program, use

 

options mprint;

Then run the program again, and see if the LOG is more clear and helps you figure out what you did wrong.

 

If you can't understand what it is telling you, then please copy the log as text (the code AND the error messages) and — DO NOT SKIP THIS STEP — paste it into the window that appears when you click on the {i} icon. 

--
Paige Miller

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

As the first line of your program, use

 

options mprint;

Then run the program again, and see if the LOG is more clear and helps you figure out what you did wrong.

 

If you can't understand what it is telling you, then please copy the log as text (the code AND the error messages) and — DO NOT SKIP THIS STEP — paste it into the window that appears when you click on the {i} icon. 

--
Paige Miller
inyli
Calcite | Level 5

Thanks! I got my problem solved. 

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
  • 3 replies
  • 382 views
  • 1 like
  • 3 in conversation