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

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.

 

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
  • 298 views
  • 1 like
  • 2 in conversation