Hi,
Is there a way to move the observations as shown below without using the sort option?
data dataset;
length Segment $13;
input Segment var1 var2 var3;
datalines;
%_of_missing 19 23 12
0 32 43 23
1-10 23 534 343
11-20 434 432 42
21-30 23 123 543
31-40 443 2342 4234
41-50 32 25243 4523
51-100 324 5234 324
;
run;
data want;
length Segment $13;
input Segment var1 var2 var3;
datalines;
0 32 43 23
1-10 23 534 343
11-20 434 432 42
21-30 23 123 543
31-40 443 2342 4234
41-50 32 25243 4523
51-100 324 5234 324
%_of_missing 19 23 12
;
run;
proc print data=dataset;
run;
proc print data=want;
run;
Given that you just want to move the first observation to the end of the data set, this should work:
data want;
set have (firstobs=2) have (obs=1);
run;
Unless I am missing something, your code does exactly what you asked for, it moves the line that begins %_of_missing to the bottom of the data set.
- how do you identify the observation that has to be moved?
- how do you determine the position in which the observation should end up (beginning, end, after another defined obs, a given obs number, ...)?
I just wanted to move 1st obs to the last obs. It's working as i expected from the below solution provided by @Astounding. Thanks for your efforts too.
Given that you just want to move the first observation to the end of the data set, this should work:
data want;
set have (firstobs=2) have (obs=1);
run;
Awesome, this is what I wanted. Thanks a lot for your contribution.
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.
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.