Solved

SAS date conversion

Posted on 2011-03-03
2
788 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
one-way data "masking" MD5 sql 26 145
How can I find a table in SQL server 2016 4 53
Data quality checks 2 50
SQL 2012 create index "incorrect syntax near 'INCLUDE'" 6 53
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
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…

910 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

21 Experts available now in Live!

Get 1:1 Help Now