Actuarial Outpost
 
Go Back   Actuarial Outpost > Actuarial Discussion Forum > Software & Technology
FlashChat Actuarial Discussion Preliminary Exams CAS/SOA Exams Cyberchat Around the World Suggestions

Salary Surveys
Pension
Property & Casualty
Life & Health

Health
Actuary Jobs

Insurance &
Consulting --
Students,
Associates &

Fellows

D.W. Simpson
& Company

International
Actuarial
Recruiters

www.dwsimpson.com

Casualty Jobs
& Property --
Students
Associates &

Fellows


Reply
 
Thread Tools Display Modes
  #1  
Old 06-15-2012, 06:50 PM
we7dude we7dude is offline
Member
 
Join Date: Jan 2009
College: Temple Alumni
Posts: 273
Default Sas min max on a column or first or last then output

Sas coding help. Let say I have the following table

Name,effdate, trandate
John,20120105,20120101
John,20120105,20120104
Mary,20120108,20120109
Mary, 20120108,20120102

And this is the output I want

John,20120105,20120101
Mary,20120108, 20120102

So the key to filter is trandate but I do not know how to code it in a data step.
Any help is appreciated.
Reply With Quote
  #2  
Old 06-16-2012, 08:33 PM
ameerzaid ameerzaid is offline
SOA
 
Join Date: Jan 2008
Location: Dubai
Posts: 10
Default

Sort your data in the order you want.

Then use the command "if first.name;"

Proc sort data = datafile ;
By name trandate ;

Data datafile01;
Set datafile;

By name trandate ;

If first.name;

Run;

You'll get the what you want.
Reply With Quote
  #3  
Old 06-20-2012, 02:34 PM
BassFreq's Avatar
BassFreq BassFreq is offline
Member
CAS
 
Join Date: Jun 2003
Location: Chicago
Studying for all eternity
Favorite beer: Duff
Posts: 1,220
Default

Alternatively, you can do the following to get the same result:
Code:
proc sql;
create table datafile01 as 
select name,effdate,min(trandate) as trandate
from datafile
group by name,effdate;
quit;
I'm assuming that you want the minimum trandate for a given name/effdate combination. Ameerzaid's code assumes the effdate is immaterial. Either method can be adjusted very slightly to recreate either assumption. If Ameerzaid's assumption is correct, then proc sql will do the same thing if you remove effdate from both the select and group by statements. If my assumption is correct, Ameerzaid's code will work if you sort "by name effdate trandate;", and then use "If first.effdate" in the data step.
__________________
Res ipsa loquitur, sed quid in infernos dicet?
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT -4. The time now is 10:13 PM.


Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
*PLEASE NOTE: Posts are not checked for accuracy, and do not
represent the views of the Actuarial Outpost or its sponsors.
Page generated in 0.22209 seconds with 9 queries