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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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