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


Reply
 
Thread Tools Display Modes
  #21  
Old 05-31-2010, 07:42 PM
Trilli@n Trilli@n is offline
 
Join Date: May 2010
Posts: 1
Default multiple linear regression

I have a model y=beta0+beta1*x1+beta2*x2+eps, eps~N(0.1)
and I need to do two test2:
1. H0:beta1=0
2. H0:beta2=0

Can someone help me to do this in SAS?
Is this correct?

PROC REG DATA = dataset;
MODEL y = x1 x2;
test x1=0 ;
test x2=0;
run;

How can I save p value from each test to a new data set?
Reply With Quote
  #22  
Old 06-02-2010, 01:28 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,670
Blog Entries: 2
Default

Quote:
Originally Posted by Trilli@n View Post
I have a model y=beta0+beta1*x1+beta2*x2+eps, eps~N(0.1)
and I need to do two test2:
1. H0:beta1=0
2. H0:beta2=0

Can someone help me to do this in SAS?
Is this correct?

PROC REG DATA = dataset;
MODEL y = x1 x2;
test x1=0 ;
test x2=0;
run;

How can I save p value from each test to a new data set?
All you need is
odsoutput ParameterEstimates=new_data_set;
PROCREGDATA = dataset;
MODEL y = x1 x2;
run;quit;

The p values will be in the column named Probt in the data set named new_data_set.
__________________
If at first you don't succeed, you have one data point.
Res ipsa loquitur, sed quid in infernos dicet?
Reply With Quote
  #23  
Old 12-09-2010, 05:40 PM
Gareth Keenan's Avatar
Gareth Keenan Gareth Keenan is offline
Member
CAS
 
Join Date: Feb 2006
Location: by a pretty big bay
Studying for #9
Favorite beer: butter
Posts: 1,272
Default two ifs

I want to create a smaller table from a larger table. My larger table has a character variable, let's say it's date. I want to filter with an if statement so that if the value for each entry in the date variable is 01feb2010 or 01april2010, then it will be included in the smaller table. All other entries for the variable date will be deleted and not included.

I know my code starts with

Data small_table;
set large_table;
if datepart(date) eq '01feb2009'd

but don't know how to include the other if statement to finish the data statement code. I'd prefer something like an Excel OR Function. I also understand an "in" may be appropriate.

Cheers,

Gareth Keenan

Suggestions?
Reply With Quote
  #24  
Old 12-10-2010, 10:28 AM
dumples dumples is offline
Member
CAS
 
Join Date: Sep 2003
Posts: 1,229
Default

You can't use an in statement?

if datepart(date) IN ('01feb2009'd, '01Apr2009'd);

?
Reply With Quote
  #25  
Old 12-10-2010, 11:35 AM
BassFreq's Avatar
BassFreq BassFreq is offline
Member
CAS
 
Join Date: Jun 2003
Location: Chicago
Studying for all eternity
Favorite beer: Duff
Posts: 1,670
Blog Entries: 2
Default

Two other options are
if datepart(date) IN ('01feb2009'd '01Apr2009'd); /* no comma works */

if datepart(date) = '01feb2009'd or datepart(date) = '01APR2009'd;
__________________
If at first you don't succeed, you have one data point.
Res ipsa loquitur, sed quid in infernos dicet?
Reply With Quote
  #26  
Old 12-10-2010, 11:36 AM
BassFreq's Avatar
BassFreq BassFreq is offline
Member
CAS
 
Join Date: Jun 2003
Location: Chicago
Studying for all eternity
Favorite beer: Duff
Posts: 1,670
Blog Entries: 2
Default

Another option:
if datepart(date) = '01feb2009'd then output;
if datepart(date) = '01APR2009'd then output;
__________________
If at first you don't succeed, you have one data point.
Res ipsa loquitur, sed quid in infernos dicet?
Reply With Quote
  #27  
Old 12-10-2010, 11:38 AM
Gareth Keenan's Avatar
Gareth Keenan Gareth Keenan is offline
Member
CAS
 
Join Date: Feb 2006
Location: by a pretty big bay
Studying for #9
Favorite beer: butter
Posts: 1,272
Default

Success! Thanks Dumples!
Reply With Quote
  #28  
Old 12-13-2010, 10:45 AM
dumples dumples is offline
Member
CAS
 
Join Date: Sep 2003
Posts: 1,229
Default

I just noticed that you're using an IF statement, one thing that you might want to consider for performance is a WHERE statement.

The big plus to a WHERE statement is performance based. As I understand it, SAS will create a record for each dataline that has a true WHERE (if there is no WHERE then every thing is true so every input line is written) and then will delete lines in statements from IF's. (IF A; is logically and calculation-ally equivalent to IF not A then DELETE; ). For big datasets, you'll see a decent time savings.

The downside is that where statements are a little bit more finicky, it won't do data type conversion, so if you're trying to work with numbers stored as text then you'll need to use a PUT or INPUT statement (I always forget which does which). Also, the conditions need to be based on fields that are in the original dataset, so if you're creating a new field during the data step, then you'll need to use an IF statement.

Last edited by dumples; 01-10-2011 at 01:52 PM..
Reply With Quote
  #29  
Old 02-09-2011, 10:30 AM
ThatGuy's Avatar
ThatGuy ThatGuy is offline
Member
 
Join Date: Aug 2010
College: I'm Old.
Posts: 1,202
Default

I created code that I want to loop through so I can pull data from different directories for different months, how do i loop my code through say from 2010 01 to 2010 12 through some code. I can explain more as needed this is vague...
Reply With Quote
  #30  
Old 02-09-2011, 11:27 AM
BassFreq's Avatar
BassFreq BassFreq is offline
Member
CAS
 
Join Date: Jun 2003
Location: Chicago
Studying for all eternity
Favorite beer: Duff
Posts: 1,670
Blog Entries: 2
Default

Two ways:
First way is with macro.
%macro blah;
%do i = 1 %to 12;
<then do things, referring to &i for number>
%end;
%mend;
%blah;

Second way would be in data step.
data _null_;set whatev;
call execute('proc copy in=a out=b;select table'||_n_);
run;
__________________
If at first you don't succeed, you have one data point.
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 03:18 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, 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.29834 seconds with 10 queries