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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.