BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi all,
I’d like to create a dataset with two columns splitting the column of another dataset.
I have a dataset like this:

data A;
length report $15;
input report;
datalines;
Germany_1
Italy_1
Italy_2
Italy_3
Germany_2
Italy_4
Germany_3
Italy_5
Italy_6
;
run;

And I need to create a new dataset based in the other one. It should be like this:

Germany_1 Italy_1
Germany_1 Italy_2
Germany_1 Italy_3
Germany_2 Italy_4
Germany_3 Italy_5
Germany_3 Italy_6

I can use the condition that the variable begins with Germany or Italy, but I don’t know how.

Can anybody help me?

Thanks!
Elena
2 REPLIES 2
deleted_user
Not applicable
use following code:

data b;
set a;
retain temp;
if _n_ = 1 then temp = report;
if index(scan(temp,1,'_'),scan(report,1,'_')) then temp = report;
if temp = report then delete;
run;

GL.

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 25. 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
  • 2 replies
  • 840 views
  • 0 likes
  • 1 in conversation