BookmarkSubscribeRSS Feed
Tejaswini3
Obsidian | Level 7

I want to combine two columns.

The dataset is

Tejaswini3_1-1654882044292.png

 

The final column should be

BODY AS A WHOLE - GENERAL DISORDERS

FATIGUE

FEVER

CENTRAL & PERIPHERAL NERVOUS SYSTEM DISORDERS

HEADACHE

 

1 REPLY 1
Reeza
Super User

For a report? Or in a data set? This seem smore like a report structure than data set structure.

 

*assumes data is sorted correctly. If order is important as in the file structure, add the word NOTSORTED to the end of the BY statement;
*replace data set and variable names as needed;
data want;
set have;
by Col2 Col1;
if first.Col2 then do;
temp=col1;
col1=col2; 
output;
col1=temp;
output;
end;
else output;
keep col1;
run;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1 reply
  • 234 views
  • 0 likes
  • 2 in conversation