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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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 lock in 2025 pricing—just $495!

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
  • 857 views
  • 2 likes
  • 3 in conversation