DATA Step, Macro, Functions and more

Macro for transforming multiple tables based on a code.

Accepted Solution Solved
Reply
Regular Contributor
Posts: 182
Accepted Solution

Macro for transforming multiple tables based on a code.

[ Edited ]

Hi everyone

A quick one. i have a code that transforms a table (ICD10 into __ICD10):

 



proc transpose data=ICD10 out=_ICD10;
var l:;
run;

proc transpose data=_ICD10 out=__ICD10;
by _name_;
var col:;
run;

data ___ICD10;
set __ICD10;
where col1 ne '';
run;

The problem is that I need to do the same thing for ICD7, ICD8, ICD9 and ICD10. My question is, is there a way to care a macro version from the above code to call and use with  ICD7-ICD10 instead of repeating the code? All intermediate files can also be deleted to avoid cluttering. 

Thanks


Accepted Solutions
Solution
‎04-24-2018 04:05 PM
PROC Star
Posts: 399

Re: Macro for transforming multiple tables based on a code.

[ Edited ]

 

rsubmit;
%macro tsp(icdNum);
proc transpose data=&icdNum out=_&icdNum; var l:; run; proc transpose data=_&icdNum out=__&icdNum; by _name_; var col:; run;
data ___&icdNum; set __&icdNum; where col1 ne ''; run;
%mend;

%tsp(ICD7);

%tsp(ICD8);
%tsp(ICD9);

%tsp(ICD10);


endrsubmit;

Might work Smiley Happy?

//Fredrik

 

View solution in original post


All Replies
Solution
‎04-24-2018 04:05 PM
PROC Star
Posts: 399

Re: Macro for transforming multiple tables based on a code.

[ Edited ]

 

rsubmit;
%macro tsp(icdNum);
proc transpose data=&icdNum out=_&icdNum; var l:; run; proc transpose data=_&icdNum out=__&icdNum; by _name_; var col:; run;
data ___&icdNum; set __&icdNum; where col1 ne ''; run;
%mend;

%tsp(ICD7);

%tsp(ICD8);
%tsp(ICD9);

%tsp(ICD10);


endrsubmit;

Might work Smiley Happy?

//Fredrik

 

☑ This topic is solved.

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

Discussion stats
  • 1 reply
  • 87 views
  • 0 likes
  • 2 in conversation