DATA Step, Macro, Functions and more

Update of Table

Accepted Solution Solved
Reply
Contributor
Posts: 22
Accepted Solution

Update of Table

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

Accepted Solutions
Solution
‎01-27-2015 04:04 AM
Super Contributor
Posts: 305

Re: Update of Table

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


All Replies
Solution
‎01-27-2015 04:04 AM
Super Contributor
Posts: 305

Re: Update of Table

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;

Contributor
Posts: 22

Re: Update of Table

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

Super User
Posts: 5,260

Re: Update of Table

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
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 208 views
  • 3 likes
  • 3 in conversation