DATA Step, Macro, Functions and more

multiple file processing in data step

Accepted Solution Solved
Reply
Contributor
Posts: 20
Accepted Solution

multiple file processing in data step


Hi,

I want to change a variable in a data.

But I want to do the same job for multiple files in a directory.

I kind of feel that I can do this efficiently if I use macro, but I do not know exactly becuase I am  just a beginner of SAS macro.

The SAS code for one file is..

data test;

set pars.prod11_beer;

COLUPC = 1*UPC

drop UPC;

run;

Any advice or suggetion from you would be greatly appreciated!

Thanks!


Accepted Solutions
Solution
‎03-14-2013 04:30 AM
Trusted Advisor
Posts: 1,137

Re: multiple file processing in data step

Hi ,

Please try the below macro

%macro dir(name=,file=,var=,var2=);

data &name;

set pars..&file;

&var= 1*&var2

drop &var2;

run;

%mend;

%dir(name=test, file=prod11_beer,var=COLUPC,var2=UPC);

Hope this helps

Thanks,

Jagadish

Thanks,
Jag

View solution in original post


All Replies
Solution
‎03-14-2013 04:30 AM
Trusted Advisor
Posts: 1,137

Re: multiple file processing in data step

Hi ,

Please try the below macro

%macro dir(name=,file=,var=,var2=);

data &name;

set pars..&file;

&var= 1*&var2

drop &var2;

run;

%mend;

%dir(name=test, file=prod11_beer,var=COLUPC,var2=UPC);

Hope this helps

Thanks,

Jagadish

Thanks,
Jag
Contributor
Posts: 20

Re: multiple file processing in data step

Posted in reply to Jagadishkatam

Thanks.

But it did not work well..

I got the error message below.

error.jpg

Do you have any idea why this happened?

Trusted Advisor
Posts: 1,137

Re: multiple file processing in data step

Hi

Please remove the additional . from pars..&file, there should be a single . like this

pars.&file

Please try and let me know the output.

Thanks,

Jagadish

Thanks,
Jag
Contributor
Posts: 20

Re: multiple file processing in data step

Posted in reply to Jagadishkatam

Thank you so much!

It worked beautifully!

Jin-Hee Huh

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 229 views
  • 3 likes
  • 2 in conversation