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;
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.
https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/... has a PDF with much information about dates.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.