Hi All,
i have data like below:
data test;
input a b c;
datalines;
1 0 0
0 1 0
0 1 1
1 1 1
;
run;
i need output with same data added one more variable result as
a b c Result
1 0 0 A1
0 1 0 B2
0 1 1 B3
1 1 1 A4
please suggest to get the result
Hello,
Could you post the code you tried and / or describe what are the diificulties of building your own solution.
I am not able to imageing anything on it or i can try array and "if " conditions but its not seems good. Can u please suggest if any thing in sort available.
Thanks in advance
Your last component appears to be the row and independent of the variable. You can get the row nimbler by using _n_.
You say first non missing value but you don't have any missing values in your data set.
Use WHICHN and VNAME to find the variable name
Array var_list(3) a b c;
Index = whichn(1, of var_list(*));
First_var = vname(var_list(index));
0 as missing value and 1 can be anything.. just to simplify i used 0 and 1,
Making sample data that doesn't reflect your situation means having to answer your question twice.
Youll have to loop through the array then to find your first non missing value. You can use LEAVE to exit a loop.
VNAME can still be used to find variable name and _n_ for row number.
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 25. 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.