BookmarkSubscribeRSS Feed
Q1983
Lapis Lazuli | Level 10

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

3 REPLIES 3
kuridisanjeev
Quartz | Level 8

Hi

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

Thanks,

Sanjeev.K

kuridisanjeev
Quartz | Level 8

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

UrvishShah
Fluorite | Level 6

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

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1355 views
  • 0 likes
  • 3 in conversation