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

Hello guys,

I have 2 problems and i will appreciate appropriate codes for each case.

 

1. The data set i attached here is called "Chuck1" and i want to sort this data so that the observations are listed (grouped) by state with the first observation having a value of 'TX' and the youngest person in that state.

 

2. I also want to write a second code that will help me sort "chuck1" so that there is only one observation per person (Subj_no identifies each person in the data set). I don't want to overwrite the original data set, but rather to put the sorted data into a new data set called 'Chuck2".

 

Help is needed!

 

Capture.JPG

1 ACCEPTED SOLUTION

Accepted Solutions
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

Please post your sample data in the form of a SAS datastep with datalines to represent the data so that we can read you sample data into a SAS dataset.

Otherwise we have to enter all your sample from a snapshot to get an understanding of the data and the data types.

 

View solution in original post

3 REPLIES 3
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

Please post your sample data in the form of a SAS datastep with datalines to represent the data so that we can read you sample data into a SAS dataset.

Otherwise we have to enter all your sample from a snapshot to get an understanding of the data and the data types.

 

Shmuel
Garnet | Level 18

A simple sort will be:

 

proc sort data=chuck1;
   by descending state age;
run;

 without duplicates:

proc sort data=chuck1 out=chuck2 nodupkey;
   by subj_no;
run;

 

ChuksManuel
Pyrite | Level 9

Thanks Shmuel!

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1333 views
  • 0 likes
  • 3 in conversation