BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Siddhu
Fluorite | Level 6
data master;
 input ID Type $ A B C;
 datalines;
 1 A 10 100 200
 2 B 15 105 300
 3 C 20 120 200
 4 B 30 125 300
 5 A 25 110 400
;
run;

I have a data set like above 

Now I need the output like

 

IMG_7976.JPG

 

The condition is for id-1 and type-A, I need to get the value of variable A for id-1 in the Value variable i.e, 10 and for id-2 and type-B I need only need to get the value of variable B for id 2 which is 105. like this let say there are so many IDs and many Types. So, now, someone please help me with a code which is fully automated for any no of IDs and Types.

1 ACCEPTED SOLUTION
5 REPLIES 5
Jagadishkatam
Amethyst | Level 16

try

 

data want;
set master;
array vars(*) a b c d ;
do i = 1 to dim(vars);
if lowcase(type)=lowcase(vname(vars(i))) then value=vars(i);
end;
run;
Thanks,
Jag
KachiM
Rhodochrosite | Level 12

@Siddhu 

 

You have already have two replies.

I want to know how you have placed the hand-written figure inside this Editor. 

hashman
Ammonite | Level 13

@KachiM

Perhaps snapped a photo if it, saved it as a file, then attached by clicking on the Photos icon. 

 

 

KachiM
Rhodochrosite | Level 12

@hashman 

 

Thank you.

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
  • 5 replies
  • 1671 views
  • 2 likes
  • 5 in conversation