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.
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.
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.