DATA Step, Macro, Functions and more

convert the char into date

Accepted Solution Solved
Reply
Contributor
Posts: 24
Accepted Solution

convert the char into date

Hi, 

 

I am reading other people's code but did not understand "??" in the following code for char into num conversion. input(strip(AESTDTC),?? yymmdd10.)

 

Can somebody help me out on this?

 

Thanks!


Accepted Solutions
Solution
‎05-24-2017 05:33 PM
Super User
Posts: 11,343

Re: convert the char into date

Please the log when you run this example code:

data example;
   mydate = input('9999/99/99', yymmdd10.)    ;
   odate  = input('9999/99/99',?? yymmdd10.)    ;
   realdt = input('2017/10/05', yymmdd10.)    ;
   format mydate odate realdt date9.;
run;

You will get an error message from the first line. The example "dates" of 9999/99/99 are one example of some coding for "missing" in some data systems that must have a value but for some reason do not have the actual value available.

 

View solution in original post


All Replies
PROC Star
Posts: 7,477

Re: convert the char into date

The ?? in the input statement will result in a missing value (with no note in the log) when the variable can't be input using the specified informat.

 

Art, CEO, AnalystFinder.com

Solution
‎05-24-2017 05:33 PM
Super User
Posts: 11,343

Re: convert the char into date

Please the log when you run this example code:

data example;
   mydate = input('9999/99/99', yymmdd10.)    ;
   odate  = input('9999/99/99',?? yymmdd10.)    ;
   realdt = input('2017/10/05', yymmdd10.)    ;
   format mydate odate realdt date9.;
run;

You will get an error message from the first line. The example "dates" of 9999/99/99 are one example of some coding for "missing" in some data systems that must have a value but for some reason do not have the actual value available.

 

Contributor
Posts: 24

Re: convert the char into date

Thank you both!

 

From the result, the day missing values are the first day of the month. Is anyway to define the missing values of both day and month similarly?

 

Best,

 

John

Super User
Posts: 11,343

Re: convert the char into date

It will help to show us what the values with missing days look like. If your dates actually have delimiter  such as / then the ANYDTDTE informat should work to imply the day of the month when missing is 01.

data example;
   informat datestr $10.;
   input datestr ;
   mydate = input(datestr,anydtdte.);
   format mydate date9.;
datalines ;
2017/01/15
2017/01   
;
run;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 134 views
  • 0 likes
  • 3 in conversation