04-14-2014 03:22 PM
I'm trying to proc export with a where clause on a date column and it's not working.
I think it has something to do with the format of the date variables: ddmmyyyy
Proc export data=MAUDE.Total1999thru2013 (where=(DATE_RECEIVED='03/10/1992'))
Error message is:
OTE: File "...\Output\test9.xls" will be created if the export process succeeds.
ERROR: WHERE clause operator requires compatible variables.
ERROR: Export unsuccessful. See SAS Log for details.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE EXPORT used (Total process time):
real time 0.85 seconds
cpu time 0.17 seconds
Any tips or wise words?
04-14-2014 05:30 PM
My data is in format dd/mm/yyyy, and I'm still getting an error, albeit a different one...
456 Proc export data=MAUDE.Total1999thru2013 where=(DATE_RECEIVED='10MAR1992'D)
457 dbms=excel file="="...\Output\test9.xls";
459 Proc export data=MAUDE.Total1999thru2013 where=(DATE_RECEIVED='10MAR1992'D)
ERROR 22-322: Syntax error, expecting one of the following: ;, (, DATA, DBLABEL, DBMS, DEBUG,
FILE, LABEL, OUTFILE, OUTTABLE, REPLACE, TABLE, _DEBUG_.
ERROR 76-322: Syntax error, statement will be ignored.
04-14-2014 05:38 PM
The error message is because you left off the closing right parenthesis for your data set options.
It does not matter what format you have chosen to display the dates the WHERE clause is going to act on the actual VALUE that is stored.
In the case of a date that is the number of days since 1/1/1960. You also just use date_received = 11757 if you wanted.
5 data _null_;
6 x='10MAR1992'd ;
7 put x= / x= date9. / x=mmddyy10. / x= yymmdd10. ;
04-14-2014 05:36 PM
Are the actual values in the date variable numbers formatted as SAS dates? If they are, Tom's suggested code should do what you want without you having to change your data.
04-14-2014 05:44 PM
Look at Tom's last response: you left off two parentheses. Instead of:
Proc export data=MAUDE.Total1999thru2013 where=(DATE_RECEIVED='10MAR1992'D)
Proc export data=MAUDE.Total1999thru2013 (where=(DATE_RECEIVED='10MAR1992'D))
Need further help from the community? Please ask a new question.