BookmarkSubscribeRSS Feed
fengyuwuzu
Pyrite | Level 9

I have a number of data files, from different providers, and they used different formats for the dates, like:

yyyymm yyyy-mm mm-yyyy yyyy/mm

 

Sometimes SAS reads in as bes12. numberic, sometimes SAS reads in as $8. characteric, and sometimes SAS automatically recognizes as date and added the day 01 to become 01MMMYY:00:00:00 format.

 

So I have to deal with every different case.

I hope there is a way that I can control the import to end up one format in SAS, so that I only need to deal with one format conversion.

Any suggestions?

 

Thank you!

3 REPLIES 3
Reeza
Super User
Welcome to the world of data analysis.

Ideally, each data provider has a standard and you can customize your code for that provider. Unfortunately there's no way to guarantee that proc import will format variables the way you want. To gain control of the format/type you need to write your own code. For CSV/TXT this is relatively easy, especially if you have data dictionaries.
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Firstly, and most important, is to get the transfer agreement in place.  This would be a document which details what data, and in what format the data is in.  Without this document you will not be sure what the data reflects, or be able to handle changes.  Once you have this setup for each vendor then the coding is very simple, a datastep import based on the agreement.  Like 90% of programming, the actual work should be in the documentation, the code then writes itself.

 

fengyuwuzu
Pyrite | Level 9
Thanks for the advice.

Now I have figured out how to convert all these formats. This is a very nice practice actually. So in future I know how to take care of these.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 821 views
  • 0 likes
  • 3 in conversation