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

Showing results for

Find a Community

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

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

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-06-2018 06:35 PM - edited 05-06-2018 06:36 PM

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.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to kelSAS

05-06-2018 07:56 PM

Hi,

Check frequency distribution of variable g before t-test.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to kelSAS

05-08-2018 06:35 PM

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