BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Data_User
Quartz | Level 8

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;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

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;

View solution in original post

5 REPLIES 5
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
Kurt_Bremser
Super User

- 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, ...)?

Data_User
Quartz | Level 8

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.

Astounding
PROC Star

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;

Data_User
Quartz | Level 8

Awesome, this is what I wanted. Thanks a lot for your contribution.

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