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