Hello I have this data with four variables A, B, C D that I want to make it one variable A. THe data is as such.
A B C D
1 1 1 .
2 1 . 1
. 2 1 .
. . 2 .
. . . 3
I want to create this data with one variable call A as above
F
1
2
2
3
The variable A B C D are in order and F takes the first number. If all are missing, F will be missing otherwise F takes the first value from the variable A, B, C, D.
The coalesce() function will pick the first non-missing value.
data sample;
input A B C D;
F=coalesce(a,b,c,d);
datalines;
1 1 1 .
2 1 . 1
. 2 1 .
. . 2 .
. . . 3
;
Actually F is: F
F
1
2
2
2
3
The coalesce() function will pick the first non-missing value.
data sample;
input A B C D;
F=coalesce(a,b,c,d);
datalines;
1 1 1 .
2 1 . 1
. 2 1 .
. . 2 .
. . . 3
;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: