Have a date field on INFILE with format CCYY.JJJ and need to convert to SAS date. Can't seem to wrap my head around this for some reason. Example of input date:
2020.350
Remove the period and use JULIAN7. informat. Or parse out the YEAR and DAYS part and re-combine them.
data test;
input str $ ;
date1=input(compress(str,'.'),julian7.);
date2=mdy(1,1,input(str,4.))+input(scan(str,2,'.'),3.)-1;
format date: yymmdd10.;
put (_all_) (=);
cards;
2020.350
2020.001
;
What should that map to? Is 350 the # of days? ie roughly December 15/16, 2020?
If so, I think that's a Julian Date.
https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.5&docsetId=leforinforref&docsetTarge...
data test;
date='2018099';
sasdate=input(date,julian7.);
put sasdate ;
put sasdate date9.;
run;
@G_I_Jeff wrote:
Have a date field on INFILE with format CCYY.JJJ and need to convert to SAS date. Can't seem to wrap my head around this for some reason. Example of input date:
2020.350
Remove the period and use JULIAN7. informat. Or parse out the YEAR and DAYS part and re-combine them.
data test;
input str $ ;
date1=input(compress(str,'.'),julian7.);
date2=mdy(1,1,input(str,4.))+input(scan(str,2,'.'),3.)-1;
format date: yymmdd10.;
put (_all_) (=);
cards;
2020.350
2020.001
;
It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.