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-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
  • 722 views
  • 0 likes
  • 1 in conversation