This widget could not be displayed.
This widget could not be displayed.
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.


Hello,  you folks helped me out immensely with figuring out how to turn the date of 1/1/1960 into a real date to be stored in an Oracle table.  I have another question on how to turn that date, which is the CURRENT date, into the PREVIOUS days date.  The following is the code.

*  This gets the current Date.

%let curday=%sysfunc(date(), date9.);

%put &curday;

* This loads the records into an Oracle table.  the date portion  hos_date is the date 7/25/2013 12:01:01 PM.  I want it to be Yesterday's Date of 7/24/2013 12:01:01 PM

proc sql;
insert into safety.safety_hrs_svc

select dhms("&curday"d,12,01,01) as hos_date, STATION, CONTR_ID, CONTR_NAME, PRIM_SVC_AREA_ID, DRIVER_NBR, DRIVER_NAME, PCK_DELV_HRS, SPOT_HRS, LINEHAUL_HRS from work.safety_hrs;
quit;

Thank you very much.

1 ACCEPTED SOLUTION

Accepted Solutions
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.

Bruno......... BANG.  YOU NAILED  IT.  Man you're good.   Do you want to fly to Pennsylvania ?   :smileylaugh:

THANKS ALL.... I LUV THIS BOARD

View solution in original post

6 REPLIES 6
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.

Try:

%let preday=%sysfunc(date()-1, date9.);

This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.

OS2, that generates the following error..... cut from the log.

11         %let prevday=%sysfunc(date()-1, date9.);

ERROR: Expected close parenthesis after macro function invocation not found.

Thanks so much for looking.

This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.

My Bad:

use:

CALL SYMPUT('predte',put(date()-1.date9.));

This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.

Fleroo


Check this code:
%let curday=%sysfunc(PUTN(%eval(%sysfunc(date()) - 1), date9.));
%put NOTE: &=curday;
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.

Bruno......... BANG.  YOU NAILED  IT.  Man you're good.   Do you want to fly to Pennsylvania ?   :smileylaugh:

THANKS ALL.... I LUV THIS BOARD

This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.

You can also use INTNX:

%let curday=%sysfunc(intnx(day,%sysfunc(date()), -1),date9.);

%put NOTE: &=curday;

Haikuo

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 6 replies
  • 11439 views
  • 1 like
  • 4 in conversation
This widget could not be displayed.
This widget could not be displayed.