SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
littleka
Calcite | Level 5

For the data set I am working with, I have a date column. For example, when looking at Excel for one row, the date value is "11/2/2020"

 

When I import into SAS and look at proc contents, it says that the entire column is a character type, $1 format. The value for the example row I gave above became 2.

 

There is another date column in the data set that isn't having this problem? Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

@littleka wrote:

For the data set I am working with, I have a date column. For example, when looking at Excel for one row, the date value is "11/2/2020"

 

When I import into SAS and look at proc contents, it says that the entire column is a character type, $1 format. The value for the example row I gave above became 2.

 

There is another date column in the data set that isn't having this problem? Thanks.


How did you read the data into SAS.  Did you use PROC IMPORT? Show the code you ran.

 

What type of file do you actually have?  If it is an actual EXCEL file such as XLSX file or even the older XLS file then what you describe cannot happen.

 

If it is instead a text file, like a CSV file, then just write your own data step to read the file and you will have full control over how the variables are read.

View solution in original post

3 REPLIES 3
Kurt_Bremser
Super User

Save the data as csv from Excel, inspect it with a text editor to see how the values are stored, and the read it with a data step according to your findings.

Tom
Super User Tom
Super User

@littleka wrote:

For the data set I am working with, I have a date column. For example, when looking at Excel for one row, the date value is "11/2/2020"

 

When I import into SAS and look at proc contents, it says that the entire column is a character type, $1 format. The value for the example row I gave above became 2.

 

There is another date column in the data set that isn't having this problem? Thanks.


How did you read the data into SAS.  Did you use PROC IMPORT? Show the code you ran.

 

What type of file do you actually have?  If it is an actual EXCEL file such as XLSX file or even the older XLS file then what you describe cannot happen.

 

If it is instead a text file, like a CSV file, then just write your own data step to read the file and you will have full control over how the variables are read.

littleka
Calcite | Level 5
I tried exporting the data file as an XLSX file and that preserved the correct format. Thanks!

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 3 replies
  • 1260 views
  • 0 likes
  • 3 in conversation