Hello,
I am trying to read raw data into a sas data set and I keep getting numbers like 1690411140. I am having trouble formatting this into a normal date, such as 8/23/2013...
Any help would be much appreciated! I am new to SAS and this one little thing is holding me up!
Example of raw data file (fake data)
Student,Points Awarded,Points Available,%,Grading Status,Finished On,Version
John Doe,10,10,100%,Graded,7/25/2015 10:39 PM,4
Code I wrote:
options validvarname=any;
data work.test;
infile 'C:\mypath\file.csv' dlm=',';
Module='Test Name';
length Student $ 20;
input Student $ Points_Awarded Points_Available '%'n percent4. Grading_Status $ Finished_On : MDYAMPM20. Version $;
format '%'n percent6. Finished_On month9.;
drop Grading_Status Points_Awarded Points_Available Version;
if Student='Student' then delete;
run;
proc print data=work.test;
run;
Output:
Test Name John Doe 100% 1690411140 (want this to be formatted as a date)
Thank you so much for your help!
Your Finished_On variable is a datetime value. There are a limited number of formats that will display the date directly from datetime, DTDATE9. probably is closest. You could either assign the format permanently by adding
format Finished_On DTdate9. ; in the data step or the same syntax in the proc print for a temporary association.
If you want more control over appearance you may want to create a date only variable such as:
Date_finished = datepart(Finished_on);
format Date_Finished mmddyy10. ;
Or pick one of the many DATE related formats.
specify a datetime or similiar format, eg:
input Finished_On : MDYAMPM20. ;
format Finished_On datetime20.;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.