Adding to @ccarel
The value of Birth_date apparently is already a SAS date value. Run proc contents on your data set and I bet you see Birth_date has Format mmddyy10.
What you did with this code:
b_date= input(Birth_date,10.);
was ask SAS to convert the existing value of Birth_date to a string value that the INPUT function requires. The unformatted value of 08Jan1966 is 2199. When SAS does the requested conversion it uses the best12. format so the resulting string 12 characters long with a value of 8 blanks followed by 2199. Then you tell SAS to read that value with 10. format so it reads the first 10 characters. The only numerals there are 21 so the result is 21. When you format that as a date you get 22 Jan 1960 because 0 is 1 Jan 1960 and dates are number of days from 1 Jan 1960. So add 21 = 22 Jan 1960.
If your value had actually been the string '01/08/1966' there would have been an error because that is not valid to read with the 10. informat.
Your log when you ran the code would have message about "Numeric values have been converted to character values at the places given by :
(Line):(Column).
the line and column shown would point to the location of Birth_date in the input function argument.
Can you provide some sample data?
can you please try with the date which has been given in the question
You need to give us a sample of your datasets credit and card (as yout set statement adresses those two datasets).
We need this to see the actual values and the variable types and attributes.
Provide the data in a data step; a macro that converts your dataset to a data step for posting is found here:
When posting, use the "little running man" or {i} icons. These preserve formatting and prevent reformatting of supposed smileys etc.
PFA for sample data set
The problem is that a csv file does not convey column attributes in any way, which are essential in getting the right answers.
Or do you mean that you do not yet have a SAS dataset and need proper import code for the csv also?
The data set i have importeed correctly but I am not understanding why I am getting different out put while using put and input
please help me on that
Show the code with which you imported the csv, so we can recreate your dataset.
Or use the macro I previously mentioned to convert your dataset into a data step for posting here.
Board monitors,
Perhaps it's time to compare this to:
Looks like there's a homework assignment here.
Oh, yeah, some people need to get a grasp on the concept that homework assignments want to test THEIR brains, not OURS.
Adding to @ccarel
The value of Birth_date apparently is already a SAS date value. Run proc contents on your data set and I bet you see Birth_date has Format mmddyy10.
What you did with this code:
b_date= input(Birth_date,10.);
was ask SAS to convert the existing value of Birth_date to a string value that the INPUT function requires. The unformatted value of 08Jan1966 is 2199. When SAS does the requested conversion it uses the best12. format so the resulting string 12 characters long with a value of 8 blanks followed by 2199. Then you tell SAS to read that value with 10. format so it reads the first 10 characters. The only numerals there are 21 so the result is 21. When you format that as a date you get 22 Jan 1960 because 0 is 1 Jan 1960 and dates are number of days from 1 Jan 1960. So add 21 = 22 Jan 1960.
If your value had actually been the string '01/08/1966' there would have been an error because that is not valid to read with the 10. informat.
Your log when you ran the code would have message about "Numeric values have been converted to character values at the places given by :
(Line):(Column).
the line and column shown would point to the location of Birth_date in the input function argument.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.