BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.

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

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

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;

View solution in original post

2 REPLIES 2
novinosrin
Tourmaline | Level 20

try

 

want=coalescec(of col1-col6);
PeterClemmensen
Tourmaline | Level 20

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;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 761 views
  • 2 likes
  • 3 in conversation