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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.