How to get results from first date with multiple labels?

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 10
Accepted Solution

How to get results from first date with multiple labels?

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


Accepted Solutions
Solution
‎08-08-2013 05:08 PM
Respected Advisor
Posts: 4,932

Re: How to get results from first date with multiple labels?

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


All Replies
Solution
‎08-08-2013 05:08 PM
Respected Advisor
Posts: 4,932

Re: How to get results from first date with multiple labels?

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
Occasional Contributor
Posts: 10

Re: How to get results from first date with multiple labels?

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

Super User
Posts: 11,343

Re: How to get results from first date with multiple labels?

Or assuming at sorted by manufacturers

data want (drop= tempSmiley Happy;

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;

Occasional Contributor
Posts: 10

Re: How to get results from first date with multiple labels?

Thank you Ballardw for your suggestion! Bo

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 186 views
  • 3 likes
  • 3 in conversation