BookmarkSubscribeRSS Feed
Flyer
Calcite | Level 5

Hi All ,

I am new to sas macro. I am getting error on the following macro, trying to debug it.

data employee1 employee2 employee3;

set department;

call symput('employee', employeeID);

output employeeID&employee;

run;


Thanks,


Diana

2 REPLIES 2
PaigeMiller
Diamond | Level 26

Macro variables created by call symput will not be available until after the RUN; statement at the end of the data step.

You don't need macros here anyway.

data employee1 employee2 employee3;

set department;

if employeeID=1 then output employee1;

else if employeeID=2 then output employee2;

else if employeeID=3 then output employee3;

run;

--
Paige Miller
Reeza
Super User

Except if you have a lot of employees that's a pain, but then you shouldn't be doing that and using by groups instead.

If you really need to split the file for some reason and can't use BY processing see the hash solution at the end of this page (the rest is interesting to know as well).

http://www.sascommunity.org/wiki/Split_Data_into_Subsets

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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