BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Astounding
PROC Star

Withus,

When Reeza suggested this:

where date between "&year-01-01" and "&year-12-31"

Did you realize that he is using double quotes, and not two single quotes?  Did you actually use double quotes and have the program still fail?

Linlin
Lapis Lazuli | Level 10

Reeza is She.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Sory to add to your mail Astounding, you would still need to have the letter d after your date literals, e.g. "&year-01-01"d

Otherwise the where is trying to compare numeric date to two characters which wont work

Reeza
Super User

The OP states it's a character variable.

My date variable is string.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

So the where is all wrong then:

from:

where Date between '&year-01-01' and '&year-12-31';

to (assuming per the other dates that my date is yyyy-mm-dd):

where input(Date,yymmdd10.) between "&year-01-01"d and "&year-12-31"d;

withus
Fluorite | Level 6

I tried, shown below:

"input(DOS, yymmdd10.)" then I got an error message: Invalid date/time "2013-01-01"d

"01Jan&year."d.    ....and another error: different data types.

For your convenience I posted fake data and code above.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 20 replies
  • 2541 views
  • 1 like
  • 8 in conversation