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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1242 views
  • 1 like
  • 3 in conversation