Hello
Why field var1 is numeric and not a sas date?
data a;
infile cards;
input var1 mmddyy10.;
cards;
01/23/1963
;
run;
SAS dates are numeric, but most of the time they have a format. So, it is correct.
data a;
infile cards;
format var1 yymmdd10.;
input var1 mmddyy10.;
cards;
01/23/1963
;
run;
So, you are using an informat, to tell SAS how to translate the text "01/23/1963
". Then SAS saves it as the number of days between that date and 1st of January 1960. Then, if you want to, you can add an "outformat" to make it more readable.
Most software solutions saves dates in this way, but the start date is often different. Microsoft Excel use 1st of January 2000 (or 1900) as a start date.
SAS dates are numeric. They are the number of days since 01/01/1960. Add a date format to your variable to see it as a date:
format var1 yymmdd10.;
@Ronein wrote:
Hello
Why field var1 is numeric and not a sas date?
data a; infile cards; input var1 mmddyy10.; cards; 01/23/1963 ; run;
VAR1 will be a date. It will be the number days since 1960. But since you didn't attach any format it will be confusing to humans, but not to SAS. If you want to make it looks like a date to a human then attach a date format. Like DATE9. or YYMMDD10.
SAS dates are numeric, but most of the time they have a format. So, it is correct.
data a;
infile cards;
format var1 yymmdd10.;
input var1 mmddyy10.;
cards;
01/23/1963
;
run;
So, you are using an informat, to tell SAS how to translate the text "01/23/1963
". Then SAS saves it as the number of days between that date and 1st of January 1960. Then, if you want to, you can add an "outformat" to make it more readable.
Most software solutions saves dates in this way, but the start date is often different. Microsoft Excel use 1st of January 2000 (or 1900) as a start date.
Once again, follow Maxim 1: Read the Documentation, in this case About SAS Date, Time, and Datetime Values, which is found in the Learning SAS Programming section under Concepts.
You will find that SAS dates are indeed numeric.
Given the number of your accumulated questions and posts, I am quite sure this has been covered already.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.