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

I have an imported dataset from excel where all dates assumed the mmddyy10. format. I noticed in a proc freq there is an observation with a date that is an obvious error I would like to fix (as it predates the observation window). 

 

Is there a way to find the observation with the date value I am looking for? A proc print that would work for normal numeric values does not work in this case. 

proc print data=a;
where date=09/01/1920;
run;

I ultimately need to change the year of this date, but that hasn't worked either. 

data b;
set a;
if date=09/01/1920 then date2=09/01/2020;
else date2=date;
run;

 

Thanks in advance. 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26
where date=09/01/1920;


SAS thinks this means: find a date whose value is equal to 9 divided by 1 divided by 1920. I'm guessing this is not what you want.

 

To indicate you have date values which you would like SAS to use, you need to use this representation exactly (except either upper or lower case is allowed). Following the string with the letter d indicates to SAS this is a date.

 

where date = '01SEP1920'd;

 

 

So when you create data b; you need to make similar changes. I leave that part up to you as a homework assignment.

--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26
where date=09/01/1920;


SAS thinks this means: find a date whose value is equal to 9 divided by 1 divided by 1920. I'm guessing this is not what you want.

 

To indicate you have date values which you would like SAS to use, you need to use this representation exactly (except either upper or lower case is allowed). Following the string with the letter d indicates to SAS this is a date.

 

where date = '01SEP1920'd;

 

 

So when you create data b; you need to make similar changes. I leave that part up to you as a homework assignment.

--
Paige Miller
sasgorilla
Pyrite | Level 9

Thank you. That did the trick and I was able to make the change. 

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1511 views
  • 1 like
  • 2 in conversation