Hi,
I am new to the SAS software. Please do help with this relatively easy question.
I want to run a regression using data from only specific rows in my file. My data is arranged by date. See a sample of my file below:
date | aa | gg | kk |
1990-01-02 | 11 | 21 | 34 |
1990-01-04 | 34 | 45 | 56 |
1990-01-07 | 86 | 5 | 67 |
1990-01-09 | 5 | 78 | 89 |
1990-01-11 | 6 | 6 | 87 |
1990-01-14 | 6 | 6 | 67 |
1990-01-17 | 66 | 6 | 67 |
1990-01-22 | 6 | 44 | 51 |
1990-01-25 | 35 | 34 | 45 |
1990-01-27 | 67 | 86 | 5 |
I want to run my regression using data starting from the 4th row (1990-01-07).
Ideally you would have a rule that is better than after the 4th row, i.e. include all rows where the date is after January 9th, because row numbers aren't included by default which means you need to first create the row numbers.
You can use a WHERE option after the data set name:
proc reg data=have (where = (date > '09Jan1990'd)) ;
Or you can add a WHERE clause in the PROC REG statement.
proc reg data=have ... ;
WHERE date > '09Jan1990'd;
@azy wrote:
Hi,
I am new to the SAS software. Please do help with this relatively easy question.
I want to run a regression using data from only specific rows in my file. My data is arranged by date. See a sample of my file below:
date aa gg kk 1990-01-02 11 21 34 1990-01-04 34 45 56 1990-01-07 86 5 67 1990-01-09 5 78 89 1990-01-11 6 6 87 1990-01-14 6 6 67 1990-01-17 66 6 67 1990-01-22 6 44 51 1990-01-25 35 34 45 1990-01-27 67 86 5
I want to run my regression using data starting from the 4th row (1990-01-07).
Hi,
Something like this? I am using a sample data set and you can try on the same pattern on your data set.
data have ;
input var1-var4 ;
n = _n_;
cards;
0.5 1 1.2 0.4
0.9 1 1.5 0.2
0.7 1 1.1 0.3
1 1 1 1
3 1 3 1
4 1 6 7
;
proc reg data=have(where = (n>3));
model var1=var2;
quit;
Ideally you would have a rule that is better than after the 4th row, i.e. include all rows where the date is after January 9th, because row numbers aren't included by default which means you need to first create the row numbers.
You can use a WHERE option after the data set name:
proc reg data=have (where = (date > '09Jan1990'd)) ;
Or you can add a WHERE clause in the PROC REG statement.
proc reg data=have ... ;
WHERE date > '09Jan1990'd;
@azy wrote:
Hi,
I am new to the SAS software. Please do help with this relatively easy question.
I want to run a regression using data from only specific rows in my file. My data is arranged by date. See a sample of my file below:
date aa gg kk 1990-01-02 11 21 34 1990-01-04 34 45 56 1990-01-07 86 5 67 1990-01-09 5 78 89 1990-01-11 6 6 87 1990-01-14 6 6 67 1990-01-17 66 6 67 1990-01-22 6 44 51 1990-01-25 35 34 45 1990-01-27 67 86 5
I want to run my regression using data starting from the 4th row (1990-01-07).
proc reg data=have (firstobs=4) ;
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.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.