Table | 1 | 2 | 3 | 4 | 5 | 6 |
1 | . |
|
|
|
|
|
1 | No |
|
|
|
|
|
2 |
| . |
|
|
|
|
2 |
| Yes |
|
|
|
|
2 |
| No |
|
|
|
|
3 |
|
| . |
|
|
|
3 |
|
| No |
|
|
|
4 |
|
|
| Yes |
|
|
5 |
|
|
|
| No |
|
5 |
|
|
|
| Yes |
|
6 |
|
|
|
|
| . |
6 |
|
|
|
|
| Yes |
My dataset looks like the sample table created above. I want to create a dataset like made below:, Any form of help will be appreciated.
F_table |
. |
No |
. |
Yes |
No |
. |
No |
Yes |
No |
Yes |
. |
Yes |
Use Coalescec Function like this
data have;
input Table (var1-var6)(:$8.);
infile datalines dlm=',' dsd missover;
datalines;
1,.,,,,,
1,No,,,,,
2,,.,,,,
2,,Yes,,,,
2,,No,,,,
3,,,.,,,
3,,,No,,,
4,,,,Yes,
5,,,,,No,
5,,,,,Yes,
6,,,,,,.
6,,,,,,Yes
;
data want(keep=F_table);
set have;
F_table=coalescec(of var:);
run;
try
want=coalescec(of col1-col6);
Use Coalescec Function like this
data have;
input Table (var1-var6)(:$8.);
infile datalines dlm=',' dsd missover;
datalines;
1,.,,,,,
1,No,,,,,
2,,.,,,,
2,,Yes,,,,
2,,No,,,,
3,,,.,,,
3,,,No,,,
4,,,,Yes,
5,,,,,No,
5,,,,,Yes,
6,,,,,,.
6,,,,,,Yes
;
data want(keep=F_table);
set have;
F_table=coalescec(of var:);
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.
Ready to level-up your skills? Choose your own adventure.