BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
itshere
Obsidian | Level 7

Hi - 

 

I imported a file into SAS and some columns were converted into number format while others into text? why is that? how do i ensure that columns are imported the way I wanted? is there a way?

 

Im using PROC SQL.. 

one of my columns that is in a TEXT format is a date  15JUL2016:00:00:00

I want to change it to a date9 format but its not letting me because its in text so I tried to do input(act_date,12.0) but when i opened the new table that column was ALL blank so the input did not work?

 

How do i convert it to a number so i can do the date9 after? Thank you very much!

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Input(a.date, datetime20.)

View solution in original post

5 REPLIES 5
Reeza
Super User

Your INPUT requires the correct informat which would be a date time format, not 12.

 

Try datetime20.

 

I'm assuming you used proc import to import your data? If so, it guesses what type/format should be, obviously not correctly always. 

 

If you have a text file you can customize your import using a data step so it's read in correctly. Unfortunately Excel doesn't play well with others and there isn't an easy way to specify types when importing from an Excel file. You can look into DBSASTYPE if you'd like to explore that route. 

itshere
Obsidian | Level 7

where would i put the datetime20.. what would be the query?

 

I import manually.. so i go to file -> Import data -> etc.

itshere
Obsidian | Level 7

right now i just have 

 

proc sql;

create table test1.discovery

select 

A.field,

A. region

input(A.date1,12.0) as

from test1.location

;

 

i tried this before but didnt work...

 

datepart(input(A.date1,12.0))

Reeza
Super User

Input(a.date, datetime20.)

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 5 replies
  • 946 views
  • 1 like
  • 3 in conversation