Solved

SAS date conversion

Posted on 2011-03-03
2
794 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

A company’s centralized system that manages user data, security, and distributed resources is often a focus of criminal attention. Active Directory (AD) is no exception. In truth, it’s even more likely to be targeted due to the number of companies …
Your data is at risk. Probably more today that at any other time in history. There are simply more people with more access to the Web with bad intentions.
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…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

717 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