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) ;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.