- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
dates vary in length. single digit months and single digit days do not have leading zeroes.
WHENCREATED
9/20/2018 7:58 AM
9/2/2018 7:00 AM
11/20/2018 9:58 AM
data WORK.CHRONIC_ABSENTEEISM;
infile 'G:\FAKEPATH\Chronic_Absenteeism.csv' delimiter = ',' MISSOVER DSD lrecl=32767 firstobs=2 ;
informat WHENCREATED ???;
format SchoolYear 4. CollectionID $4. DISTRICTCODE 4.;
input SchoolYear CollectionID $ DISTRICTCODE WHENCREATED;
run;
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Use the mdyampm informat, as suggested by @andreas_lds, and a proper datetime format for display:
data want;
infile cards dlm=',' truncover;
input
schoolyear :4.
collectionid :$4.
districtcode :$4.
whencreated :mdyampm25.
;
format whencreated e8601dt20.;
cards;
2018,AAAA,AAAA,9/20/2018 7:58 AM
2018,BBBB,BBBB,9/2/2018 7:00 AM
2018,CCCC,CCCC,11/20/2018 9:58 AM
;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Do you want a date or datetime? They are different.
Unless you have reason to suspect that you have incomplete or partial dates you might try ANYDTDTM32.
Assign a datetime19. or longer format to display a 4 digit year.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello Sir,
Good Morning !!
Thank you for your suggestion on above question . I applied informat and format as mention. But while applying format datetime20. or datetime19. , view of date & time got change. if i applied only any date format then it's working perfectly.
Here is my code.
data test;
input date anydtdte32.;
format date datetime20.;
cards;
9/20/2018 7:58 AM
9/2/2018 7:00 AM
11/20/2018 9:58 AM
;
run;
here is output . Looking for your suggestion .
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You have a date and not a datetime.
Use
format date date9.;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Try mdyampm20. as informat, instead of anydtdte32.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You are using WRONG informat .
input date anydtdtm32.;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I don't get an error when using anydtdtm32.; but it returns all values as missing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@singhsahab wrote:
Hello Sir,
Good Morning !!
Thank you for your suggestion on above question . I applied informat and format as mention. But while applying format datetime20. or datetime19. , view of date & time got change. if i applied only any date format then it's working perfectly.
Here is my code.
data test;
input date anydtdte32.;
format date datetime20.;
cards;
9/20/2018 7:58 AM
9/2/2018 7:00 AM
11/20/2018 9:58 AM
;
run;
here is output . Looking for your suggestion .
I suggested ANYDTDTM32 and expected to be reading from an external file. Your input would be incorrect in data lines as you are not accounting for spaces
data test; infile datalines dsd; input date anydtdtm32.; format date datetime20.; cards; 9/20/2018 7:58 AM 9/2/2018 7:00 AM 11/20/2018 9:58 AM ; run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Use the mdyampm informat, as suggested by @andreas_lds, and a proper datetime format for display:
data want;
infile cards dlm=',' truncover;
input
schoolyear :4.
collectionid :$4.
districtcode :$4.
whencreated :mdyampm25.
;
format whencreated e8601dt20.;
cards;
2018,AAAA,AAAA,9/20/2018 7:58 AM
2018,BBBB,BBBB,9/2/2018 7:00 AM
2018,CCCC,CCCC,11/20/2018 9:58 AM
;
run;