BookmarkSubscribeRSS Feed
KalaBhairava
Quartz | Level 8

I have data like

20170822,

NK/NK/2017        how i can convert data into date9 format...?

13 REPLIES 13
Patrick
Opal | Level 21

To what date would you expect the string NK/NK/2017 to get resolved? 01Jan2017? ...or something else?

KalaBhairava
Quartz | Level 8
I want that variable in date9. Format,
Shmuel
Garnet | Level 18

@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.

KalaBhairava
Quartz | Level 8

In one variable i want dates like

 

22aug2017

Nk/NK/2017

23aug2018

KalaBhairava
Quartz | Level 8

No it should be NK/NK/2017 only

andreas_lds
Jade | Level 19

Not clear what you have and what you need.

 

"NK/NK/2017" is not a date in any calendar i have seen so far.

KalaBhairava
Quartz | Level 8

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

 

Kurt_Bremser
Super User

@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.

KalaBhairava
Quartz | Level 8

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

Kurt_Bremser
Super User

@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.

Shmuel
Garnet | Level 18

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;
KalaBhairava
Quartz | Level 8

Thank you very much Sir..

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 13 replies
  • 2730 views
  • 1 like
  • 5 in conversation