Programming the statistical procedures from SAS

t-test after regression by year

Reply
Occasional Contributor
Posts: 16

t-test after regression by year

[ Edited ]

I am trying to run regression of GDP on Investment by year, and want to t-test the coefficient on investment by dividing the sample into two groups in the middle year of all years. For this, I had the following.

 

proc reg data=work noprint outest=investdata;
    by year;
    model gdp=investm1 invest investp1;
run;

 

investm1 and investp1 are lag and lead values of invest because I needed to control them in the regression.

 

Then for t-test, 

I split the years into g=0 or 1 at the mid-year of sample years using data step on dataset 'investdata'.

 

Then I typed in 

proc ttest data=investdata;
class g;
var invest;
run;

 

 

I get error message saying I don't have n,std,mean. Desired output would be whether coefficient on invest is significantly different from before and after at the five percent significance level. 

 

Where did I do wrong? Is there other ways I could possibly get the output that I want? Thank you for your help in advance.

Trusted Advisor
Posts: 1,270

Re: t-test after regression by year

Hi,

 

Check frequency distribution of variable g before t-test.

Super User
Posts: 13,591

Re: t-test after regression by year


@kelSAS wrote:

I am trying to run regression of GDP on Investment by year, and want to t-test the coefficient on investment by dividing the sample into two groups in the middle year of all years. For this, I had the following.

 

proc reg data=work noprint outest=investdata;
    by year;
    model gdp=investm1 invest investp1;
run;

 

investm1 and investp1 are lag and lead values of invest because I needed to control them in the regression.

 

Then for t-test, 

I split the years into g=0 or 1 at the mid-year of sample years using data step on dataset 'investdata'.

 

Then I typed in 

proc ttest data=investdata;
class g;
var invest;
run;

 

 

I get error message saying I don't have n,std,mean. Desired output would be whether coefficient on invest is significantly different from before and after at the five percent significance level. 

 

Where did I do wrong? Is there other ways I could possibly get the output that I want? Thank you for your help in advance.


Proc Ttest has two forms. One involves having multiple records for each value of your class and var variables. SAS then calculates the means, standard deviations and such from the data. The other is a test involving the summarized data with the statistics provided by you for each level of the class variable. If you don't provide enough records of the class and var variables then SAS assumes you are attempting to use a summarized data set. In which case the data is expected to have a field named _stat_ containing the n, mean, std of the variable invest for two levels of the class variable.

 

I have to say I am having a very hard time telling what

I split the years into g=0 or 1 at the mid-year of sample years using data step on dataset 'investdata'

actually means in data terms. I don't see a variable that looks like it would have sufficient information to determine a "mid-year" to "split" on. Or does your "year" variable carry more than year information with it? if so, what does your data actually look like? How many "years" do you have data for?

 

Ask a Question
Discussion stats
  • 2 replies
  • 189 views
  • 0 likes
  • 3 in conversation