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

Dear All,

I have one data set. There are three scanners and each has two time points measurements with four different label results. I would like to get only the first time point results from these three scanners. But I can only get the first label results if I use the first option. Here is my code and data set I have and results I would like to have.

proc sort data=have; by Manufacturers study_date label ;run;

data want;

   set have;

   by Manufacturers study_date  label;

   if first.study_date;

run;

what I have:

ManufacturersStudy_DateLabelmhpostmhantmhmidmhupmhlow
  N851488-Jan-13L167.2565.8861.5082.0582.81
  N851488-Jan-13L268.4872.6062.5084.1488.10
  N851488-Jan-13L369.8380.6367.5884.5987.05
  N851488-Jan-13L467.6079.5570.6089.1993.35
  N8514819-May-13L167.3465.4661.5882.3983.10
  N8514819-May-13L268.0472.9463.8085.3687.90
  N8514819-May-13L369.0076.9066.8286.6588.14
  N8514819-May-13L467.5079.4472.1288.9692.19
  N852571-Apr-13L167.2566.2561.8081.1982.42
  N852571-Apr-13L270.4574.3565.3084.0085.05
  N852571-Apr-13L370.5078.8066.2086.8589.84
  N852571-Apr-13L466.2578.9073.3088.0992.12
  N852576-Jun-13L166.8066.3261.4482.3782.78
  N852576-Jun-13L268.1674.0863.2084.3086.04
  N852576-Jun-13L368.7877.9465.8486.8188.15
  N852576-Jun-13L466.8678.6072.0288.6292.43
  N8528621-Feb-13L167.7867.0063.3581.5581.90
  N8528621-Feb-13L268.8373.1564.5884.7085.91
  N8528621-Feb-13L369.5578.0866.7385.1986.96
  N8528621-Feb-13L467.7080.3570.8088.2392.32
  N8528620-Apr-13L166.5266.1061.5881.1982.04
  N8528620-Apr-13L267.2672.1062.4684.7786.14
  N8528620-Apr-13L369.4676.9665.7884.7487.23
  N8528620-Apr-13L467.8278.7271.8087.4290.34

what I want:

ManufacturersStudy_DateLabelmhpostmhantmhmidmhupmhlow
  N851488-Jan-13L167.2565.8861.5082.0582.81
  N851488-Jan-13L268.4872.6062.5084.1488.10
  N851488-Jan-13L369.8380.6367.5884.5987.05
  N851488-Jan-13L467.6079.5570.6089.1993.35
  N852571-Apr-13L167.2566.2561.8081.1982.42
  N852571-Apr-13L270.4574.3565.3084.0085.05
  N852571-Apr-13L370.5078.8066.2086.8589.84
  N852571-Apr-13L466.2578.9073.3088.0992.12
  N8528621-Feb-13L167.7867.0063.3581.5581.90
  N8528621-Feb-13L268.8373.1564.5884.7085.91
  N8528621-Feb-13L369.5578.0866.7385.1986.96
  N8528621-Feb-13L467.7080.3570.8088.2392.32

Thank you so much for your help in advance,

Bo

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

You have to sort by label before study_date :

proc sort data=have; by Manufacturers label study_date;run;

data want;

   set have;

   by Manufacturers label;

   if first.label;

run;

PG

PG

View solution in original post

4 REPLIES 4
PGStats
Opal | Level 21

You have to sort by label before study_date :

proc sort data=have; by Manufacturers label study_date;run;

data want;

   set have;

   by Manufacturers label;

   if first.label;

run;

PG

PG
ddchina
Calcite | Level 5

Thank you so much for your prompt help PGStats! It works! Bo

ballardw
Super User

Or assuming at sorted by manufacturers

data want (drop= temp:);

set have;

by Manufacturers ;

length tempman $ 40;

retain tempman tempdate;

if first.Manufacturers then do;

tempman=Manufacturers;

tempdate=study_date;

end;

if tempman=Manufacturers and

   tempdate=study_date;

run;

ddchina
Calcite | Level 5

Thank you Ballardw for your suggestion! Bo

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 696 views
  • 3 likes
  • 3 in conversation