BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hello, I know that this has to be an easy fix for you savvy SAS users;
I formatted the date from generic SAS datetime to this:

DATA V_DATE; SET CERTS; BDATE=DATEPART(BDATE); RUN;
PROC SORT DATA=V_DATE; BY BDATE; FORMAT BDATE mmddyy10.; RUN; OPTIONS COMPRESS=YES; RUN;

And now when I try to search for specific dates within V_DATE it tells me that BDATE has been defined as both character and numeric, although when I do a proc contents it tells me it is numeric.

DATA MISSING; IF BDATE IN(
'01/22/2006'
'02/14/2006'
'02/21/2006'
'03/05/2006'
'03/17/2006'
'03/18/2006'
'03/19/2006'
'03/24/2006'
'04/24/2006'
'05/08/2006'
'05/30/2006'
'06/12/2006'
'06/13/2006'
'06/17/2006'
'07/26/2006'
'09/28/2006'
'10/06/2006'
'10/23/2006'
'12/11/2006'
'12/18/2006'
'12/31/2006'
'01/04/2007'
'01/17/2007'
'01/26/2007'
'02/14/2007'
'05/16/2007'
'05/30/2007'
'07/18/2007'
'07/19/2007'
'08/15/2007'
'10/04/2007'
'10/05/2007'
'10/24/2007'
'11/08/2007'
'12/26/2007'); SET V_DATE;OPTIONS COMPRESS=YES; RUN;

It tells me this: Variable BDATE has been defined as both character and numeric.

grrrrrrr!!!! HELP 🙂 ?
1 REPLY 1
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
A few items to correct and some suggestions:

1) Your IF statement must follow the SET statement.
2) The correct method to code a date-literal requires you specify a trailing "D" character after the quoted string -- such as '01jan2009'd.
3) Suggestion: move your FORMAT statement to be in the DATA step where you are transforming the "purpose" of BDATE - from a DATETIME variable to a DATE (numeric) variable, mostly for relevance.
4) Suggestion: remove the redundant OPTIONS COMPRESS=YES; statement -- that CONFIG option had already been set with the first statement.
5) Suggestion (depending on your data-volume) either change the IF statement to a WHERE statement or also consider using a PROC FORMAT to accomplish your look-up / data-filtering processing for optimized performance.
6) Suggestion: explore the use of SAS views (or an index) for further performance optimization, where applicable.

Scott Barry
SBBWorks, Inc.

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1 reply
  • 1223 views
  • 0 likes
  • 2 in conversation