DATA Step, Macro, Functions and more

sas macro code

Reply
Not applicable
Posts: 1

sas macro code

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

Respected Advisor
Posts: 3,000

Re: sas macro code

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
Super User
Posts: 23,700

Re: sas macro code

Posted in reply to PaigeMiller

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

Ask a Question
Discussion stats
  • 2 replies
  • 190 views
  • 0 likes
  • 3 in conversation