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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 3 replies
  • 827 views
  • 0 likes
  • 3 in conversation