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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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