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
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.
See my answer in your other thread
https://communities.sas.com/t5/SAS-Programming/SAS-real-time-scenario/m-p/589030
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;
See my answer in your other thread
https://communities.sas.com/t5/SAS-Programming/SAS-real-time-scenario/m-p/589030
You have already have two replies.
I want to know how you have placed the hand-written figure inside this Editor.
Perhaps snapped a photo if it, saved it as a file, then attached by clicking on the Photos icon.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.