BookmarkSubscribeRSS Feed
alexanthonymaj0
Calcite | Level 5

Hi everyone,

 

I am getting all of my desired results, except my date formatting is incorrect. Currently, the date is formatted as "06-Aug-89" (it also comes up in the results this way) and I would like it to be  formatted as 06/11/1989. Does anyone have any suggestions? 

Here is my code:

 

libname employee '/home/alexanthonymaj0/my_courses/rahmansarker/c_8568';

data emp123;
          length FirstName $ 14 LastName $ 20 JobTitle $ 22;
          infile '/home/alexanthonymaj0/my_courses/rahmansarker/c_8568/emp_50490.csv' dlm=',';
          input EmployeeID FirstName $ LastName $ Gender $ Salary JobTitle $ Country $ HireDate $;
          format HireDate $ddmmyy. Salary dollar8.;
drop Gender Country;

run;

 

proc print data=emp123;
run;

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20

Hi and welcome to the SAS communities 🙂

 

Try this code 

 

libname employee '/home/alexanthonymaj0/my_courses/rahmansarker/c_8568';

data emp123;
          length FirstName $ 14 LastName $ 20 JobTitle $ 22;
          infile '/home/alexanthonymaj0/my_courses/rahmansarker/c_8568/emp_50490.csv' dlm=',';
          input EmployeeID FirstName $ LastName $ Gender $ Salary JobTitle $ Country $ HireDate $;
          format HireDate ddmmyy10. Salary dollar8.;
drop Gender Country;

run;

proc print data=emp123;
run;

 

In your original code, you specified  a character format (with a $). A date format is a numeric format. Also, remember to specify a length along with the format, as in ddmmyy10.

Astounding
PROC Star
With a slight modification to the end of the suggested INPUT statement which now reads:

... Hiredate $ ;

Change that to:

... Hiredate : date9. ;

That gives you a numeric date that you can format as ddmmyy10.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 991 views
  • 0 likes
  • 4 in conversation