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;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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