11-01-2016 04:35 AM
i have data like below:
input a b c;
1 0 0
0 1 0
0 1 1
1 1 1
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
11-01-2016 04:47 AM
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
11-01-2016 04:53 AM - edited 11-01-2016 04:55 AM
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));
11-01-2016 05:12 AM
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.