Hi I have a date like 20180101 which is Numeric 8 and I need to transform it to YYMMDDN8.
I am doing it just with a proc sql but it's not working well...
like this
SELECT t1.DN_PEO FORMAT=YYMMDDN8.;
The date is after written like this:
*******************
and still in num 8.
Do you know where is the problem here?
Sounds like you are trying to do something like the following:
data have; input DN_PEO; cards; 20180101 ; proc sql; create table want as select input(put(DN_PEO,8.),yymmdd8.) as DN_PEO format=YYMMDDN8. from have ; quit;
Art, CEO, AnalystFinder.com
Date values in SAS are stored as number of days from 1st Jan 1960. In your example your saying SAS that 20180101 days form 1st Jan 1960. Which is why you are getting *****. First thing is you need to tell SAS how to read data otherwise it will follow its nature.
I suggest use @art297 solution. Converting the numeric values into character and then telling SAS to convert back into numeric date values.
Also you need to understand about FORMAT(How to show data) and INFORMAT (How to read data).
Hi,
I have the same problem here!
I used this:
input(put(t1.DAT,8.),YYYYMMDD8.)
And the solution doesn't work for me.
I modified the format to YYMMDDN8., so the format is well going from numeric8. to date8. but I also have
*******************
for every date.
Do you know why?
Some of values of DAT at the top rows of the table are null. Can it explain?
Thanks
You'd have to provide an example of your data. My guess is that your dates are already either date or datetime values and you simply need to add the desired format.
I suggest that you create a new thread and ask your question there.
Art, CEO, AnalystFinder.com
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.