Solved

SAS date conversion

Posted on 2011-03-03
2
787 Views
Last Modified: 2013-11-16
When I import an Excel file into SAS it gives me this date fromat:
12OCT2008, (DATE9 format and informt).

I want to convert that date as it exist now in the file (i.e. I don't want to convert it during the
import process) to TEXT so that I looks and feels like:
2008-10-12.

I need the date to be TEXT because I also have missing dates in the file
and I need to lable the missing values "NS".  

Pleaase advise.   Thanks.
0
Comment
Question by:WTH_LOL
2 Comments
 
LVL 14

Accepted Solution

by:
Aloysius Low earned 500 total points
ID: 35032908
what you can do is to use Excel to prepare the data first, since it's your requirement that you wanted as it is now in the file not on import.

the excel formula you could use to convert a date field into the character string format that you required is =TEXT([cell],"yyyy-mm-dd")

in this case, import will recognise the new field as a character and import as such.
0
 
LVL 11

Expert Comment

by:theartfuldazzler
ID: 35034047
Hi

SAS will often try to "guess" whether a field is text or numeric based on the first few rows.  If the field looks like a date, then it assumes the whole table is dates.

If you want SAS to guess from all the rows (not just the first few) then SAS recommends that you adjust the registry (make a back up of the registry just in case).  If you have "NS" in the missing fields, in excel, then SAS will import the date field as text:


Start ->  Run

Enter Regedt32 select OK.

Open this key in the Registry Editor window:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\Access Connectivity Engine\Engines\Excel

Double-click TypeGuessRows.

Select Decimal, enter 0 in the Value field, and select OK.

Exit from the Registry Editor window.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction: I have seen many questions on EE and elsewhere, asking about how to find either gaps in lists of numbers (id field, usually) ranges of values or dates overlapping date ranges combined date ranges I thought it would be a good …
Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now