The input source is by a human to manually keyed the MEMBERID and DOB.
I have update the script, still have the error. T.T
options symbolgen mlogic mlogicnest mprint;
%let input_string =%nrbquote([{"MEMBERID": "A123456", "DOB": "2022-03-03"}]);
data json_text;
json_text="&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.);
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 into: DOB from Parse_JSON;
select case when DOB EQ "" then 0
case when DOB EQ input(DOB,?yymmdd10.) then 2
else 1 end
into :DOB_IND
from Parse_JSON;
quit;
%put &inv_MEMBERID_ind;
%put &DOB_IND;
The below is the log:
1 The SAS System 16:30 Thursday, March 3, 2022
1 ;*';*";*/;quit;run;
2 OPTIONS PAGENO=MIN;
3 %LET _CLIENTTASKLABEL='Program 4';
4 %LET _CLIENTPROCESSFLOWNAME='Standalone Not In Project';
5 %LET _CLIENTPROJECTPATH='';
6 %LET _CLIENTPROJECTPATHHOST='';
7 %LET _CLIENTPROJECTNAME='';
8 %LET _SASPROGRAMFILE='';
9 %LET _SASPROGRAMFILEHOST='';
10
11 ODS _ALL_ CLOSE;
12 OPTIONS DEV=PNG;
13 %macro HTML5AccessibleGraphSupported;
14 %if %_SAS_VERCOMP_FV(9,4,4, 0,0,0) >= 0 %then ACCESSIBLE_GRAPH;
15 %mend;
16 FILENAME EGSR TEMP;
17 ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
18 STYLE=HTMLBlue
19 NOGTITLE
20 NOGFOOTNOTE
21 GPATH=&sasworklocation
SYMBOLGEN: Macro variable SASWORKLOCATION resolves to
"C:\Users\xxxxxxxx\AppData\Roaming\SAS\EnterpriseGuide\EGTEMP\SEG-23212-76e80bec\contents\SAS Temporary
Files\_TD25752_NCS-5CG12517WL_\Prc2/"
22 ENCODING=UTF8
23 options(rolap="on")
24 ;
NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
25
26 options symbolgen mlogic mlogicnest mprint;
27 %let input_string =%nrbquote([{"MEMBERID": "A123456 ", "DOB": "2022-03-03"}]);
28
29 data json_text;
30 json_text="&input_String.";
SYMBOLGEN: Macro variable INPUT_STRING resolves to [{"MEMBERID": "A123456 ", "DOB": "2022-03-03"}]
SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been unquoted for printing.
31 run;
NOTE: The data set WORK.JSON_TEXT has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds
32
33 data Parse_JSON (drop=json_text drop=regex01 drop=regex02);
34 set WORK.json_text;
35 retain
36 regex01
37 regex02
38 ;
39 if _N_ = 1 then do;
40 regex01=prxparse("/(.+?)MEMBERID(.+?)DOB/");
41 regex02=prxparse("/(.+?)DOB(.+?)\}/");
42 end;
43
2 The SAS System 16:30 Thursday, March 3, 2022
44 if prxmatch(regex01, json_text) then do;
45 MEMBERID=strip(tranwrd(tranwrd(tranwrd(upcase(prxposn(regex01, 2, json_text)),":",""),",",""),'"',""));
46 end;
47 if prxmatch(regex02, json_text) then do;
48 DOB=input(strip(tranwrd(tranwrd(tranwrd(upcase(prxposn(regex02, 2, json_text)),":",""),",",""),'"',"")),YYMMDD10.);
49 end;
50 run;
NOTE: There were 1 observations read from the data set WORK.JSON_TEXT.
NOTE: The data set WORK.PARSE_JSON has 1 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.03 seconds
51
52
53 proc sql noprint;
54 /*Assign Macro vars to Params for ERRmsg*/
55 select compress("'"||%nrquote(MEMBERID)||"'") into: MEMBERID from Parse_JSON;
55 !
56 select
57 case when MEMBERID in ("",".") then 1
58 else 0 end into: inv_MEMBERID_ind from Parse_JSON;
59
60 select DOB into: DOB from Parse_JSON;
61 select case when DOB EQ "" then 0
62 case when DOB EQ input(DOB,?yymmdd10.) then 2
____
22
202
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, <, <=, <>, =, >, >=, ?, AND, BETWEEN,
CONTAINS, ELSE, END, EQ, EQT, GE, GET, GT, GTT, IN, IS, LE, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, WHEN, ^, ^=,
|, ||, ~, ~=.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
63 else 1 end
64 into :DOB_IND
65 from Parse_JSON;
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
66 quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
SYMBOLGEN: Macro variable INV_MEMBERID_IND resolves to 0
67
68 %put &inv_MEMBERID_ind;
0
69 %put &DOB_IND;
SYMBOLGEN: Macro variable DOB_IND resolves to 1
1
70
71
72
73 %LET _CLIENTTASKLABEL=;
3 The SAS System 16:30 Thursday, March 3, 2022
74 %LET _CLIENTPROCESSFLOWNAME=;
75 %LET _CLIENTPROJECTPATH=;
76 %LET _CLIENTPROJECTPATHHOST=;
77 %LET _CLIENTPROJECTNAME=;
78 %LET _SASPROGRAMFILE=;
79 %LET _SASPROGRAMFILEHOST=;
80
81 ;*';*";*/;quit;run;
82 ODS _ALL_ CLOSE;
83
84
85 QUIT; RUN;
86
I wish to get:
Macro variable DOB_IND resolves to 0 when DoB is empty Macro variable DOB_IND resolves to 1 when DoB is correctly keyed Macro variable DOB_IND resolves to 2 when DoB is wrongly keyed
How can I fix it?
Thank you
... View more