BookmarkSubscribeRSS Feed
kelSAS
Obsidian | Level 7

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.

2 REPLIES 2
stat_sas
Ammonite | Level 13

Hi,

 

Check frequency distribution of variable g before t-test.

ballardw
Super User

@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?

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1799 views
  • 0 likes
  • 3 in conversation