BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
RACHEL2425
Fluorite | Level 6

Hi everyone-

 

I am currently doing a simple linear regression of a variable over time. My date format right now is in the format (mmddyyyy) [no forward slashes, no letters]. Whenever I try to include a "where" statement when I do proc reg, errors come up. Can anyone help with this? I have included two of the codes that I have tried below: 

 

PROC REG DATA=work.ELYRIA PLOTS = (FITPLOT);
where '03/24/2021'd <= sasdate <= '04/25/2021'd ;
MODEL LOGMGC = sasdate;
RUN;

 

or 

 

PROC REG DATA=work.ELYRIA PLOTS = (FITPLOT);
where 03/24/2021'd <= sasdate <= 04/25/2021 ;
MODEL LOGMGC = sasdate;
RUN;

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

A SAS date literal must be in the form

"DDMMMYYYY"d

where DD is the day of the month, MMM the three-letter month abbreviation (e.g JAN for January), and YYYY is the year. Therefore, your WHERE statement must be

where "24mar2021"d <= sasdate <= "25apr2021"d;

View solution in original post

3 REPLIES 3
RACHEL2425
Fluorite | Level 6
PROC REG DATA=work.ELYRIA PLOTS = (FITPLOT);
where 03/24/2021 <= sasdate <= 04/25/2021 ;
MODEL LOGMGC = sasdate;
RUN;

^error with second code in original post. I have fixed it here.
Kurt_Bremser
Super User

A SAS date literal must be in the form

"DDMMMYYYY"d

where DD is the day of the month, MMM the three-letter month abbreviation (e.g JAN for January), and YYYY is the year. Therefore, your WHERE statement must be

where "24mar2021"d <= sasdate <= "25apr2021"d;
RACHEL2425
Fluorite | Level 6
Kurt, YOU ARE A GENIUS. I cannot thank you enough. This worked. After a three hour long battle.

You are the best.

Have a lovely day.

Rachel

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 384 views
  • 1 like
  • 2 in conversation