DATA Step, Macro, Functions and more

Macro for repeating variables

Reply
Frequent Contributor
Posts: 141

Macro for repeating variables

data investor1;  
set investor ;  
Col_group = substr(d_col_group,3);  
Col_group_sort=substr(d_col_group,1,1);  
if ls_step_cd ='322' then do; step_desc ='QA Apprvd RPP';Point_Value=1;if Col_group = 'A' then Col_group_sort='E';end;  
if ls_step_cd ='322' then do; step_desc ='QA Apprvd RPP';Point_Value=1;if Col_group = 'B' then Col_group_sort='C';end;
if ls_step_cd ='322' then do; step_desc ='QA Apprvd RPP';Point_Value=1;if Col_group = 'C' then Col_group_sort='F';end;
if ls_step_cd ='323' then do; step_desc ='QA Apprvd ;Point_Value=1;if Col_group = 'A' then Col_group_sort='E';end;  
if ls_step_cd ='323' then do; step_desc ='QA Apprvd ;Point_Value=1;if Col_group = 'B' then Col_group_sort='C';end;
if ls_step_cd ='323' then do; step_desc ='QA Apprvd ;Point_Value=1;if Col_group = 'C' then Col_group_sort='F';end;

   
run;

I am trying to do a macro.  In this for each step_cd there will be several scenarios.  The step_decr and the point value will be the same for each step_cd.  The col_group and col_group sort will vary depending on the col_group.  Instead of listing each scenario, I want to do a macro based on the scenarios I just described

Super Contributor
Posts: 276

Re: Macro for repeating variables

Hi

Can you post the sample data and required format .That would help us to clearly understand your requirement.

Thanks,

Sanjeev.K

Super Contributor
Posts: 276

Re: Macro for repeating variables

And As per my understanding,no need of using macros for your senario.

You can create a user defined format for displaying Col_group_sort column based on the Col_group values.

I simplified your code.Can you test bellow code on your data.

Proc format ;

value $ Grpsort

      "A"="E"

         "B"="C"

         "C"="F"

         ;

         run;

Data Want;

Set Have;

if ls_step_cd ='322' then do;

step_desc ='QA Apprvd RPP';Point_Value=1;

Col_group_sort=put(Col_group,$Grpsort.);

end;

if ls_step_cd ='323' then do;

step_desc ='QA Apprvd' ;Point_Value=1;

Col_group_sort=put(Col_group,$Grpsort.);

end;

Run;

Thanks,

Sanjeev.K

Regular Contributor
Posts: 195

Re: Macro for repeating variables

Hi,

In this case, you need to fix how many instances of step_cd and col_group...If there's so many subjects of step_cd and col_group then only you should think about Macros or formats...

Based on SAS Codes, it will be difficult to answer your question so please post some sample data and output you want...

-Urvish

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