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

I exported excel file to sas, ex:  for some reason date in excel is ddmmmyyy (15oct2020)  converted to character days variable (41250, character) how I can bring it back to 15oct2020 in my proc report.

excel date=15oct202-

sas dataset=41250- character variable

I want in proc report as 15oct2020

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

The best solution is to fix the Excel file so the column with the date values does not have any cells with strings instead of dates.  Then SAS won't have to convert the numbers to character strings.

 

Otherwise convert the string to a number and adjust for the difference in how SAS and Excel count days.

sas_date = input(excel_string,32.) + '30DEC1899'd ;
format sas_date date9.;

View solution in original post

5 REPLIES 5
SASuserlot
Barite | Level 11

Correction its imported from excel to SAS

Tom
Super User Tom
Super User

The best solution is to fix the Excel file so the column with the date values does not have any cells with strings instead of dates.  Then SAS won't have to convert the numbers to character strings.

 

Otherwise convert the string to a number and adjust for the difference in how SAS and Excel count days.

sas_date = input(excel_string,32.) + '30DEC1899'd ;
format sas_date date9.;
SASuserlot
Barite | Level 11

Thanks  a lot it worked.👍👍. Just curios if I want display it as 08-aug-2019, i need use date 11.?

Tom
Super User Tom
Super User
With a width of 11 the DATE format will add hyphens. But if you need it to display the month using lowercase letters you will need to make a custom format.
SASuserlot
Barite | Level 11

sounds great,  it worked in both, I am fine with AUG capitals. Thanks.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1486 views
  • 2 likes
  • 2 in conversation