Help using Base SAS procedures

How to use proc sql on ..

Reply
N/A
Posts: 0

How to use proc sql on ..

My dataset looks like this:

Subject START STARTL END ENDL
1001 10Jan2010 10Jan10 12Jan2010 12Jan10
1001 15Jan2010 15Jan10 17Jan2010 17Jan10
1001 17Jan2010 17Jan10 18Jan2010 18Jan10
1001 19Jan2010 19Jan10 20Jan2010 20Jan10

I want to get min(start) and corresponding startL, max(start) and corresponding startL per subject. How can I do this using proc sql.
Super User
Posts: 9,671

Re: How to use proc sql on ..

[pre]
data temp;
input Subject (START STARTL END ENDL) (: date9.);
format START STARTL END ENDL date9.;
datalines;
1001 10Jan2010 10Jan10 12Jan2010 12Jan10
1001 15Jan2010 15Jan10 17Jan2010 17Jan10
1001 17Jan2010 17Jan10 18Jan2010 18Jan10
1001 19Jan2010 19Jan10 20Jan2010 20Jan10
;
run;
proc sql;
select subject,start,startl
from temp
group by subject
having start=min(start)
;
quit;
[/pre]

Ksharp
Respected Advisor
Posts: 3,887

Re: How to use proc sql on ..

proc sql;
select subject,start,startl,end,endl
from temp
group by subject
having start=min(start) or start=max(start)
;
quit;
N/A
Posts: 0

Re: How to use proc sql on ..

Thanks Ksharp and Patrick.
Ask a Question
Discussion stats
  • 3 replies
  • 113 views
  • 0 likes
  • 3 in conversation