DATA Step, Macro, Functions and more

Julian Date Format

Reply
N/A
Posts: 0

Julian Date Format

Hi,
I am facing problem in julian date. when i give "2007001" as julian date, it gives "02JAN" for Date5. format. But i need the output as "01JAN" for "2007001".
Please help me to resolve this ASAP. I gave my code and output.

Data _null_;
informat k julian7.;
input julian_date julian7.;
k=2007001;
put julian_date date9.;
put "K=" k date9.;
datalines;
2007001
2008001
run;


output:-
01JAN2007
K=26DEC7454
01JAN2008
K=26DEC7454

why its working differently for datalines and assigment date value. But i need the same output for assigment date value as dataline date value. Please help me.

Thanks,
Selvi Message was edited by: Selvi
Frequent Contributor
Frequent Contributor
Posts: 77

Re: Julian Date Format

Posted in reply to deleted_user
SAS is assuming that the date you are trying to represent - 2007001 - is a numeric value for the number of days past 01Jan1960. In this case 2,007,001 days. Try using the datejul function. This will give you your desired results.

k=datejul(2007001);

> Hi,
> I am facing problem in julian date. when i give
> "2007001" as julian date, it gives "02JAN" for Date5.
> format. But i need the output as "01JAN" for
> "2007001".
> Please help me to resolve this ASAP. I gave my code
> and output.
>
> Data _null_;
> informat k julian7.;
> input julian_date julian7.;
> k=2007001;
> put julian_date date9.;
> put "K=" k date9.;
> datalines;
> 2007001
> 2008001
> run;
>
>
> output:-
> 01JAN2007
> K=26DEC7454
> 01JAN2008
> K=26DEC7454
>
> why its working differently for datalines and
> assigment date value. But i need the same output for
> assigment date value as dataline date value. Please
> help me.
>
> Thanks,
> Selvi
>
> Message was edited by: Selvi
Ask a Question
Discussion stats
  • 1 reply
  • 165 views
  • 0 likes
  • 2 in conversation