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

@Programming

Novice SAS Programmer here: I have a very large datasets I am combing through, however I am running into a issue with how I might go about automating the consolidation of a repeated measures arrangement into a new dataset. Some background information which might help orient the community to the attached sample document "SAS_question.csv":

  1. The score uses the "+" and "-" as they are meaningful -- these are stored as text variables in SAS.
  2. I want to find and select the lowest value (this will exclusively be the "-" values) for a given individual (denoted by ID)
  3. After locating the lowest value for a given individual, I want to put that into a new dataset

How should the code be written to accomplish this? I am willing to learn what will be the easiest way to accomplish this.

 

Further background -- this will be for COVID-19 related research and I am trying to get this valuable information out to the medical community ASAP. Any help would be greatly appreciated!!

 

1 ACCEPTED SOLUTION

Accepted Solutions
4 REPLIES 4
ballardw
Super User

Question, why are your + and - values character? Pretty much a trivial exercise if they are numeric.

 

For example if the score is numeric:

proc summary data=have nway;
   class id;
   var score;
   output out=work.summary (drop=_type_) min=;
run;

Would create a new data set with the Id, the smallest score (and an extra variable _freq_ with the number of records that ID had in the starting set , you could remove it by adding it to the Drop list).

 

Here is how to read that data in so score is numeric:

data have;
   infile "d:\path\SASQuestion.csv" dlm=',' ;
   input id $ score;
run;

 

add4514
Fluorite | Level 6

I didn't even think of that!!!! 

 

Thank you!!! 🙂

ChrisNZ
Tourmaline | Level 20

>I have a very large datasets

Are these SAS data sets? If so just run this:

proc  sql;

  select ID, min(SCORE) from TABLE group by ID;

quit;

add4514
Fluorite | Level 6

great idea!!!!

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