Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Analytics
- /
- Stat Procs
- /
- Re: t-test after regression by year

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 05-06-2018 06:35 PM
(1800 views)

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Hi,

Check frequency distribution of variable g before t-test.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

**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.

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.