Okay, so again following as @mkeintz suggested earlier. I created a custom format: proc format; picture mdyampms (default=24) low-high= '%G/%0m/%0d %0I:%0M:%0S %p' (datatype=datetime); run; But there's a caveat, when I specify format=mdyampms22 in proc sql below, the datetime correctly reads as YYYY/MM/SS HH:MM:SS AM/PM in a new column, which is great, but when I try to create a frequency plot (see last snippets of code) the dates do not show up on the x-axis, whereas they do show up on the xaxis of a frequency plot when I type in the non-customized format= mdyampm22 in the proc sql statement (illustrated at the end of this reply) Following along the lines as what @Tom suggests and incorporating into proc sql: (I noticed that in proc contents the Informat is blank): proc sql; create table impact2 as select *,input(compress(contact_date,'[]'),ANYDTDTM24.) as fcontact_date format=mdyampms22. FROM impact; quit; proc contents data=impact2; run; proc print data=impact2; run; Or alternatively I can forgo proc sql and again follow more along what @Tom suggested but use a data step: /* mdyampms22. is from the custom format created earlier */ data impact2; set impact; fcontact_date = input(compress(contact_date,'[]'),anydtdtm24.); format contact_date mdyampms22.; put fcontact_date=; run; proc contents data=impact2; run; proc print data=impact2; run; But even using the datastep method, the values do not show up on the xaxis of a frequency plot (see below) /*** Analyze date variables ***/ title "Minimum and Maximum Dates"; proc sql; select "fcontact_date" label="Date variable", min(fcontact_date) format=MDYAMPMS22. label="Minimum date" , max(fcontact_date) format=MDYAMPMS22. label="Maximum date" from impact2; quit; title "Date Frequencies"; proc freq data=impact2 noprint; tables fcontact_date / out=_tmpfreq1; run; proc sgplot data=_tmpfreq1; yaxis min=0 minor ; xaxis minor type=time; series x=fcontact_date y=count; run; proc delete data=_tmpfreq1; run; Date variable Minimum date Maximum date fcontact_date 2010/12/28 01:53:57 PM 2026/09/19 10:44:42 AM with format=mdyampms22. Again, specifying mdyampm22. instead of the custom mdyampms22. in proc sql ultimately inputs the year labels on the xaxis of the frequency plot (BUT, again, years 1923 and 1926 are being treated as 2023 and 2026): This begs the question of if using the picture statement to create the custom format mdyampms22. is necessary? proc sql; create table impact2 as select *,input(compress(contact_date,'[]'),ANYDTDTM24.) as fcontact_date format=mdyampm22. FROM impact; quit; title "Minimum and Maximum Dates"; proc sql; select "fcontact_date" label="Date variable", min(fcontact_date) format=MDYAMPM22. label="Minimum date" , max(fcontact_date) format=MDYAMPM22. label="Maximum date" from impact2; quit; title "Date Frequencies"; proc freq data=impact2 noprint; tables fcontact_date / out=_tmpfreq1; run; proc sgplot data=_tmpfreq1; yaxis min=0 minor ; xaxis minor type=time ; series x=fcontact_date y=count; run; proc delete data=_tmpfreq1; run; Date variable Minimum date Maximum date fcontact_date 12/28/2010 1:53 PM 9/19/2026 10:44 AM with format=mdyampm22.
... View more