BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
01SASUser
Fluorite | Level 6

I have a table that looks like this:

Col1Col2Col3
1st
2nd
3rdInfoInfo
4th

What I want to do is I will update the values of Col2 and Col3 by getting the value of Col2 and Col3 in the next row.

For example, after updating my initial table, it should now look like this

Col1Col2Col3
1st
2nd InfoInfo
3rd
4th
1 ACCEPTED SOLUTION

Accepted Solutions
Loko
Barite | Level 11

Hello,

data have;
infile datalines truncover;
input Col1 $ Col2 $ Col3 $ ;
datalines;
1st  
2nd  
3rd Info Info
4th
;

data want;
merge have(keep=col1) have(drop=col1 firstobs=2);
run;

View solution in original post

3 REPLIES 3
Loko
Barite | Level 11

Hello,

data have;
infile datalines truncover;
input Col1 $ Col2 $ Col3 $ ;
datalines;
1st  
2nd  
3rd Info Info
4th
;

data want;
merge have(keep=col1) have(drop=col1 firstobs=2);
run;

01SASUser
Fluorite | Level 6

I tried the program and it worked! thanks for helping! Smiley Happy

LinusH
Tourmaline | Level 20

There's got to be more rules that could apply to this update, no? What about id/by variables, sort order...?

Unless, you could just copy paste in a view data window....

Data never sleeps

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
  • 873 views
  • 3 likes
  • 3 in conversation