<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Check the input of date is a correct input format of the date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Check-the-input-of-date-is-a-correct-input-format-of-the-date/m-p/800122#M314710</link>
    <description>&lt;P&gt;Simplify the question, you have a lot of code here, that really you don't need to have to explain the issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think based on your &lt;A href="https://communities.sas.com/t5/SAS-Programming/How-to-detect-date-input-between-wrong-format-and-empty-input/m-p/800076#M314685" target="_self"&gt;previous post&lt;/A&gt; and this one, that this is what you want to do:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
	infile cards ;
	input dates : $12. wantedResult ;
	put dates= @25 wantedResult= ;

cards ;
2022-Feb-03 2
2022-02-03 1
. 0
2020-02-41 2
;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here's what that generates&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;429  data have ;
430      infile cards ;
431      input dates : $12. wantedResult ;
432      put dates= @25 wantedResult= ;
433
434  cards ;

dates=2022-Feb-03       wantedResult=2
dates=2022-02-03        wantedResult=1
dates=                  wantedResult=0
dates=2020-02-41        wantedResult=2
NOTE: The data set WORK.HAVE has 4 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


439  ;
440  run ;
&lt;/PRE&gt;
&lt;P&gt;You want to know what code logic you need to get wantedResult&amp;nbsp; based on the value of dates (yes I know I hard coded it, but this is to explain the question, so we understand what you are trying to do).&lt;BR /&gt;&lt;BR /&gt;I'm going to say the same thing I said in the prior post:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;EM&gt;How are the values keyed in manually?&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Look at any Web page these days, if you need to enter a date, it forces you to use a specific format. This is the way to go, much easier to enforce the correct value at the time of entry than attempt to fix/catch it later.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;There's a saying "Rubbish|Trash In = Rubbish|Trash out"&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 04 Mar 2022 12:43:39 GMT</pubDate>
    <dc:creator>AMSAS</dc:creator>
    <dc:date>2022-03-04T12:43:39Z</dc:date>
    <item>
      <title>Check the input of date is a correct input format of the date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-the-input-of-date-is-a-correct-input-format-of-the-date/m-p/800098#M314694</link>
      <description>&lt;P&gt;Hi Instructures,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the below code, which I need to check the DOB is a correct input format; the DOB can have three different cases: empty input, correct input date format, and the wrong input date format according to the input_string&amp;nbsp;&lt;CODE class=" language-sas"&gt;[{"MEMBERID": "A123456", "DOB": "2022-FEB-03"}]&lt;/CODE&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let input_string =%nrbquote([{"MEMBERID": "A123456", "DOB": "2022-FEB-03"}]);

data json_text;
json_text="&amp;amp;input_String.";
run;

data Parse_JSON (drop=json_text drop=regex01 drop=regex02);
set WORK.json_text;
	retain 
		regex01
		regex02
;
  	if _N_ = 1 then do; 
		regex01=prxparse("/(.+?)MEMBERID(.+?)DOB/"); 
		regex02=prxparse("/(.+?)DOB(.+?)\}/"); 
	end;

	if prxmatch(regex01, json_text) then do;
		MEMBERID=strip(tranwrd(tranwrd(tranwrd(upcase(prxposn(regex01, 2, json_text)),":",""),",",""),'"',""));
    end;
	if prxmatch(regex02, json_text) then do;
/*		DOB=input(strip(tranwrd(tranwrd(tranwrd(upcase(prxposn(regex02, 2, json_text)),":",""),",",""),'"',"")),YYMMDD10.);*/
		DOB=strip(tranwrd(tranwrd(tranwrd(upcase(prxposn(regex02, 2, json_text)),":",""),",",""),'"',""));

end;
run;


proc sql noprint;
	/*Assign Macro vars to Params for ERRmsg*/
	select compress("'"||%nrquote(MEMBERID)||"'") into: MEMBERID from Parse_JSON;	
	select 
		case when MEMBERID in ("",".") then 1 
		else 0 end into: inv_MEMBERID_ind from Parse_JSON;

/*	select DOB as DoB_ format=yymmddd10. informat=yymmddd10. into: DOB from Parse_JSON;*/
	select compress("'"||%nrquote(DOB)||"'") into: DOB from Parse_JSON;
	select 
		case when DOB in ("",".") then 0 /*when date is empty*/
		case when DOB=input(dequote(strip(DOB)),yymmdd10.) then 1 /*when date formate is correct*/
		else 2 end into: DOB_IND from Parse_JSON;/*when date formate is wrong format*/
quit;

%put &amp;amp;DOB_IND;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;in this example should expected that log will show&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;SYMBOLGEN: Macro variable DOB_IND resolves to 2&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The source of input is key manually so it need to able to caught the wrong format of the input.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kindly help!&lt;/P&gt;</description>
      <pubDate>Fri, 04 Mar 2022 09:58:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-the-input-of-date-is-a-correct-input-format-of-the-date/m-p/800098#M314694</guid>
      <dc:creator>sarahzhou</dc:creator>
      <dc:date>2022-03-04T09:58:35Z</dc:date>
    </item>
    <item>
      <title>Re: Check the input of date is a correct input format of the date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-the-input-of-date-is-a-correct-input-format-of-the-date/m-p/800122#M314710</link>
      <description>&lt;P&gt;Simplify the question, you have a lot of code here, that really you don't need to have to explain the issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think based on your &lt;A href="https://communities.sas.com/t5/SAS-Programming/How-to-detect-date-input-between-wrong-format-and-empty-input/m-p/800076#M314685" target="_self"&gt;previous post&lt;/A&gt; and this one, that this is what you want to do:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
	infile cards ;
	input dates : $12. wantedResult ;
	put dates= @25 wantedResult= ;

cards ;
2022-Feb-03 2
2022-02-03 1
. 0
2020-02-41 2
;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here's what that generates&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;429  data have ;
430      infile cards ;
431      input dates : $12. wantedResult ;
432      put dates= @25 wantedResult= ;
433
434  cards ;

dates=2022-Feb-03       wantedResult=2
dates=2022-02-03        wantedResult=1
dates=                  wantedResult=0
dates=2020-02-41        wantedResult=2
NOTE: The data set WORK.HAVE has 4 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


439  ;
440  run ;
&lt;/PRE&gt;
&lt;P&gt;You want to know what code logic you need to get wantedResult&amp;nbsp; based on the value of dates (yes I know I hard coded it, but this is to explain the question, so we understand what you are trying to do).&lt;BR /&gt;&lt;BR /&gt;I'm going to say the same thing I said in the prior post:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;EM&gt;How are the values keyed in manually?&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Look at any Web page these days, if you need to enter a date, it forces you to use a specific format. This is the way to go, much easier to enforce the correct value at the time of entry than attempt to fix/catch it later.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;There's a saying "Rubbish|Trash In = Rubbish|Trash out"&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Mar 2022 12:43:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-the-input-of-date-is-a-correct-input-format-of-the-date/m-p/800122#M314710</guid>
      <dc:creator>AMSAS</dc:creator>
      <dc:date>2022-03-04T12:43:39Z</dc:date>
    </item>
    <item>
      <title>Re: Check the input of date is a correct input format of the date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-the-input-of-date-is-a-correct-input-format-of-the-date/m-p/800134#M314716</link>
      <description>&lt;P&gt;People might mistakly key the date in wrong format, my goal is to triggle the error message:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if &amp;amp;CountMemberID.&amp;gt;1 %then %do;
	errmsg="Multiple member found, please enter the DOB for the member.
	run;
	%goto SkipTB;
%end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;EM&gt;&lt;CODE class=" language-sas"&gt;%if &amp;amp;CountMemberID.&amp;gt;1 and &amp;amp;DOB_ind. = 2 %then %do;
	errmsg="Invalid Input DOB formate, please enter DOB in YYYY-MM-DD format
	run;
	%goto SkipTB;
%end;&lt;/CODE&gt;&lt;/EM&gt;&lt;/PRE&gt;
&lt;P&gt;and when&amp;nbsp;&lt;CODE class=" language-sas"&gt;&amp;amp;CountMemberID.=1&lt;/CODE&gt;&amp;nbsp;the script is able to located the member and return the shopping history for that member.( In reality the MemberID should not have the duplication, but some member are quite long time ago, the numbering system for the member ID might have the duplicate members)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's why I need the macro&amp;nbsp;&lt;EM&gt;&lt;CODE class=" language-sas"&gt;&amp;amp;DOB_ind.&lt;/CODE&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I rectify my code T.T&lt;/P&gt;</description>
      <pubDate>Fri, 04 Mar 2022 13:27:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-the-input-of-date-is-a-correct-input-format-of-the-date/m-p/800134#M314716</guid>
      <dc:creator>sarahzhou</dc:creator>
      <dc:date>2022-03-04T13:27:18Z</dc:date>
    </item>
    <item>
      <title>Re: Check the input of date is a correct input format of the date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-the-input-of-date-is-a-correct-input-format-of-the-date/m-p/800168#M314732</link>
      <description>&lt;P&gt;You really do need to explain why your input appears to be JSON text in a macro variable. Why isn't the input just two macro variables with the values of MEMBERID and DOB?&amp;nbsp; Forcing the use of JSON is just complicating the issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like your data step is now successfully converting the JSON text into two character variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not clear why you keep trying to code SQL steps, you do not seem to understand the syntax.&amp;nbsp; You cannot have a SELECT without a FROM.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is much easier to use normal SAS code.&amp;nbsp; You could do it in the same data step that is parsing the JSON.&lt;/P&gt;
&lt;P&gt;Here is how to do starting with the output of the other data step as input.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set parse_json;
  call symputx('memberid',quote(trim(memberid),"'"));
  call symputx('dob',dob);
  if strip(dob) in (' ' '.') then dob_ind=0;
  else if not missing(input(dob,??yymmdd10.)) then dob_ind=1;
  else dob_ind=2;
  call symputx('dob_ind',dob_ind);
run;

%put &amp;amp;=memberid;
%put &amp;amp;=dob;
%put &amp;amp;=dob_ind;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results:&lt;/P&gt;
&lt;PRE&gt;809   %put &amp;amp;=memberid;
MEMBERID='A123456'
810   %put &amp;amp;=dob;
DOB=2022-FEB-03
811   %put &amp;amp;=dob_ind;
DOB_IND=2

&lt;/PRE&gt;</description>
      <pubDate>Fri, 04 Mar 2022 14:38:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-the-input-of-date-is-a-correct-input-format-of-the-date/m-p/800168#M314732</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-03-04T14:38:01Z</dc:date>
    </item>
    <item>
      <title>Re: Check the input of date is a correct input format of the date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-the-input-of-date-is-a-correct-input-format-of-the-date/m-p/800246#M314757</link>
      <description>&lt;P&gt;Thank you! It worked.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Mar 2022 17:18:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-the-input-of-date-is-a-correct-input-format-of-the-date/m-p/800246#M314757</guid>
      <dc:creator>sarahzhou</dc:creator>
      <dc:date>2022-03-04T17:18:11Z</dc:date>
    </item>
    <item>
      <title>Re: Check the input of date is a correct input format of the date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-the-input-of-date-is-a-correct-input-format-of-the-date/m-p/800299#M314777</link>
      <description>&lt;P&gt;Hello&lt;BR /&gt;This can also be solved using libname json as shown here (&lt;A href="https://communities.sas.com/t5/SAS-Programming/Return-a-input-string-as-a-JSON-table/td-p/788653" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Return-a-input-string-as-a-JSON-table/td-p/788653&lt;/A&gt;&amp;nbsp;)&lt;BR /&gt;Following this approach the code will be&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let input_string =%nrbquote([{"MEMBERID": "A123456", "DOB": "2022-FEB-03"}]);
filename j temp;
data _null_;
file j;
put "&amp;amp;input_string";
run;
libname data json fileref=j;
data output;
 set data.root;
  if not missing(input(DOB,??yymmdd10.)) then DOB_IND=1;
  else DOB_IND=2;
run;
proc print data=output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The output will be like as follows.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Sajid01_0-1646440958469.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69167i9624868BCCE266C5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Sajid01_0-1646440958469.png" alt="Sajid01_0-1646440958469.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Mar 2022 00:43:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-the-input-of-date-is-a-correct-input-format-of-the-date/m-p/800299#M314777</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2022-03-05T00:43:28Z</dc:date>
    </item>
    <item>
      <title>Re: Check the input of date is a correct input format of the date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-the-input-of-date-is-a-correct-input-format-of-the-date/m-p/800531#M314950</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The same code when I added one more member, it has a wired bug ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let input_string =%nrbquote([{"MEMBERID1": "A12345690", "DOB1": "unknown", "MEMBERID2": "A12345677", "DOB2": "2022-01-03"}]);

data json_text;
json_text="&amp;amp;input_String.";
run;

data Parse_JSON_OID (drop=json_text drop=regex01 drop=regex02 drop=regex03 drop=regex04);
set WORK.json_text;
	retain 
        regex01
		regex02
        regex03
		regex04
;
  	if _N_ = 1 then do; 
		regex01=prxparse("/(.+?)MEMBERID1(.+?)DOB1/"); 
		regex02=prxparse("/(.+?)DOB1(.+?)\}/"); 
        regex03=prxparse("/(.+?)MEMBERID2(.+?)DOB1/"); 
		regex04=prxparse("/(.+?)DOB2(.+?)\}/"); 
	end;
	if prxmatch(regex01, json_text) then do;
		MEMBERID1=strip(tranwrd(tranwrd(tranwrd(upcase(prxposn(regex01, 2, json_text)),":",""),",",""),'"',""));
    end;

	if prxmatch(regex02, json_text) then do;
		DOB1=strip(tranwrd(tranwrd(tranwrd(upcase(prxposn(regex02, 2, json_text)),":",""),",",""),'"',""));
    end;

	if prxmatch(regex03, json_text) then do;
		MEMBERID2=strip(tranwrd(tranwrd(tranwrd(upcase(prxposn(regex03, 2, json_text)),":",""),",",""),'"',""));
    end;
	if prxmatch(regex04, json_text) then do;
		DOB2=strip(tranwrd(tranwrd(tranwrd(upcase(prxposn(regex04, 2, json_text)),":",""),",",""),'"',""));
    end;run;



data _null_;
  set Parse_JSON_OID;
  call symputx('MEMBERID1',quote(trim(MEMBERID1),"'"));
  call symputx('DOB1',DOB1);
  if strip(DOB1) in (' ' '.') then dob1_ind=0;
  else if not missing(input(DOB1,??yymmdd10.)) then dob1_ind=1;
  else dob1_ind=2;
  call symputx('dob1_ind',dob1_ind);

  call symputx('MEMBERID2',quote(trim(MEMBERID2),"'"));
  call symputx('DOB2',DOB2);
  if strip(DOB2) in (' ' '.') then dob2_ind=0;
  else if not missing(input(DOB2,??yymmdd10.)) then dob2_ind=1;
  else dob2_ind=2;
  call symputx('dob2_ind',dob2_ind);
run;

%put &amp;amp;=MEMBERID1;
%put &amp;amp;=MEMBERID2;
%put &amp;amp;=dob1;
%put &amp;amp;=dob2;
%put &amp;amp;=dob1_ind;
%put &amp;amp;=dob2_ind;
%put &amp;amp;dob1_ind;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sarahzhou_0-1646619823915.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69193iF6951C6F82A0CB19/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sarahzhou_0-1646619823915.png" alt="sarahzhou_0-1646619823915.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and the DOB1_IND is wrong in this case.&lt;/P&gt;
&lt;P&gt;How can I resolve both DOB1_IND and DOB2_IND correctly as before?&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2022 02:26:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-the-input-of-date-is-a-correct-input-format-of-the-date/m-p/800531#M314950</guid>
      <dc:creator>sarahzhou</dc:creator>
      <dc:date>2022-03-07T02:26:01Z</dc:date>
    </item>
    <item>
      <title>Re: Check the input of date is a correct input format of the date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-the-input-of-date-is-a-correct-input-format-of-the-date/m-p/800883#M315128</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/402346"&gt;@sarahzhou&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;There are many approaches to solve your issue.&lt;BR /&gt;I would use the following. I have modified your input string to a json format.&lt;BR /&gt;Adding any number of users would not create an issue.&lt;BR /&gt;Have a look at the code below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let input_string =%nrbquote([{"MEMBERID": "A12345690", "DOB": "unknown"}, {"MEMBERID": "A12345677", "DOB": "2022-01-03"}]);
filename j temp;

data _null_;
file j;
put "&amp;amp;input_string";
run;

libname data json fileref=j;
data output;
 set data.root; 
  if not missing(input(DOB,??yymmdd10.)) then DOB_IND=1;
  else DOB_IND=2;
run;&lt;BR /&gt;
proc print data=output;&lt;BR /&gt;var MEMBERID DOB DO_IND;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Your output will come out as follows. For memberid A12345690 the date is not in the date format or essentiall it is missing so DOB_IND=2. For the other memberid, THE DOB is available and it is 1.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Sajid01_0-1646756020243.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69254iEC70BEC6172024A2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Sajid01_0-1646756020243.png" alt="Sajid01_0-1646756020243.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2022 16:16:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-the-input-of-date-is-a-correct-input-format-of-the-date/m-p/800883#M315128</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2022-03-08T16:16:09Z</dc:date>
    </item>
    <item>
      <title>Re: Check the input of date is a correct input format of the date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-the-input-of-date-is-a-correct-input-format-of-the-date/m-p/801890#M315621</link>
      <description>Wow...Thank you! It worked. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Mon, 14 Mar 2022 02:10:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-the-input-of-date-is-a-correct-input-format-of-the-date/m-p/801890#M315621</guid>
      <dc:creator>sarahzhou</dc:creator>
      <dc:date>2022-03-14T02:10:21Z</dc:date>
    </item>
  </channel>
</rss>

