BookmarkSubscribeRSS Feed
jbs23
Calcite | Level 5

Good morning!

 

I have a dataset like this

 

ID                              V1                       V2                V3                        V4                V5                  V6           ..           

a2a2a2a2a2a2a2a 19259999999 19269999999 19269999999 19259999999 19279999999 19289999999    ..     

 

I want to split V1, V2...V50 into two variables like this 

 

ID                              V11     V12       V21       V22     V31       V32                

a2a2a2a2a2a2a2a 1925  9999999  1926  9999999 1926   9999999     etc

 

 

thansk for all!!

3 REPLIES 3
RW9
Diamond | Level 26 RW9
Diamond | Level 26

First question, why do you have a dataset like that.  You won't just find this particular problem harder, you will find all coding with that structure harder.  As such your current question makes no sense.

It is however possible:

data want1 (keep=id var1--var10)
     want2 (keep=id var11--var50);
  set have;
run;

But as I say, it makes no sense.  Normalise the data items (so they go down) and then process them as data elements.

KachiM
Rhodochrosite | Level 12

If you want split variables, for V1,  use:

v21 = int(V1 / 1e7);
v22 = mod(V1, 1e7);

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Oh, is that what he meant!  Still doesn't make much sense, but more than splitting variables between datasets.  If they are character then just substr().

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
  • 3 replies
  • 465 views
  • 4 likes
  • 3 in conversation