turn on suggestions

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
- /
- How do I generated confidence Intervals for 2-year...

Topic Options

- Subscribe to 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
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-15-2017 11:20 AM

Hello,

My dataset is in the following format

Year Exposure Outcome

2001 10 35

2002 23 45

2003 12 78

2004 17 70

2005 27 80

2006 59 100

2007 39 190

2008 20 391

2009 60 192

2010 10 53

Both Exposure and Outcome are continuous variables. I have constructed a simple linear regression model with Exposure as the independent variable and Outcome as the dependent variable.

Based on the results of the linear regression, I have manually generated predicted values of the Outcome for given exposure values with 2-year lag period (e.g. prediction for 2003 based on 2001 exposure). How can I automate this process in SAS because I need the corresponding 95% confidence intervals for the predicted values?

Thank you.

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

Posted in reply to ImSame

04-15-2017 11:28 AM

The simple linear regression can be done like this

```
data have;
input Year Exposure Outcome;
datalines;
2001 10 35
2002 23 45
2003 12 78
2004 17 70
2005 27 80
2006 59 100
2007 39 190
2008 20 391
2009 60 192
2010 10 53
;
proc reg data = have;
model Outcome = Exposure / cli clm;;
run;
```

Though I am not sure what you are askeing regardring lagging values? Do you want to lag values of outcome before of after the regression analysis?

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

Posted in reply to draycut

04-15-2017 11:41 AM

Thank you for your response.

The abovementioned code gives a regression equation as follows,

Outcome = Constant + Beta*Exposure

Outcome = 83.23453 + 1.45002*Exposure

If I want to predict Outcome for 2005, then it would be 122.4 (83.23453+ 1.45002*(27)). However, if I lag the exposure by 2-year period, then it would be 100.6 (83.23453+ 1.45002*(12)). SAS does the former automatically, but I need to automate the latter because I need the corresponding confidence intervals for the predicted values based on 2-year exposure lag. I hope this clarified the question.

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

Posted in reply to ImSame

04-15-2017 10:58 PM

Use lag2() funtion, after got the predict value.

```
data have;
input Year Exposure Outcome;
datalines;
2001 10 35
2002 23 45
2003 12 78
2004 17 70
2005 27 80
2006 59 100
2007 39 190
2008 20 391
2009 60 192
2010 10 53
;
run;
proc reg data = have noprint;
model Outcome = Exposure ;
output out=pred p=p lcl=low ucl=upper;
quit;
data want;
set pred;
lag2_p=lag2(p);
lag2_low=lag2(low);
lag2_upper=lag2(upper);
run;
```