I have data like
20170822,
NK/NK/2017 how i can convert data into date9 format...?
To what date would you expect the string NK/NK/2017 to get resolved? 01Jan2017? ...or something else?
@KalaBhairava, pay attention:
the given date 20170822 when displayed in date9. format will look like: 22AUG2017.
when given date is NK/NK/2017 - what do you want to display as DAY and what as MONTH ?
NK is not numeric valid DAY and not a valid MONTH.
Your answer to @Patrick is not clear.
In one variable i want dates like
22aug2017
Nk/NK/2017
23aug2018
No it should be NK/NK/2017 only
@KalaBhairava wrote:
No it should be NK/NK/2017 only
Then you can only store this data-crap as text, not as SAS dates.
Not clear what you have and what you need.
"NK/NK/2017" is not a date in any calendar i have seen so far.
NK means unknown date values i want present all values in one variable ,for more information please find below variable start data
Startdate
07-AUG-2017
11-AUG-2017
08-AUG-2017
NK NK 2018
NK NK NK
07-AUG-2017
@KalaBhairava wrote:
NK means unknown date values i want present all values in one variable ,for more information please find below variable start data
Startdate
07-AUG-2017
11-AUG-2017
08-AUG-2017
NK NK 2018
NK NK NK
07-AUG-2017
AND WHAT SHOULD BE USED IN PLACE OF 'NK' FOR MONTH AND DAY???
A SAS date ALWAYS(!!!) needs a day and month, period. It describes exactly one existing day of a year.
And NK NK NK is of course totally unusable, but there you could at least create a valid missing value.
I need to present it as NK/NK/2017 in date variable if i converted into date9. the NK will become blank i want it as NK/NK/2017
@KalaBhairava wrote:
I have data like
20170822,
NK/NK/2017 how i can convert data into date9 format...?
You can't, as NK/NK/2017 is not a date. I don't know of a day NK in any calender system I can think of, and NK isn't a month either.
I understand that your input date si a char type,
with normal date in a format of yyyymmdd, then you can try do:
length new_date $10;
test_date = input(date, ?? yymmdd8.).
if test_date = . then new_date = date;
else new_date = put(date,date9.);
drop test_date;
Thank you very much Sir..
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.