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

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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