1 + proc sql noprint; 1 + create table test1 as select distinct LBTESTCD as testcd length=8, "LB" as dataset length=8,"LBCAT" as catvar length=8,"LBSCAT" as scatvar length=8,"LBTESTCD" as testvar length=8,"LBORRES" as resultvar length=8,LBCAT as cat 2 + length=200,LBSCAT as scat length=200,LBTEST as test length=40, max(length(strip(LBORRES))) as length, case when max(compress(LBORRES)) eq ' ' then 'All missing' when compress(LBORRES,'1234567890') eq '.' then 'float' when compress(LBORRES,'1234567890') 3 + eq ' ' then 'integer' when input(LBORRES,anydtdte12.) ne . then 'datetime' else 'text' end as type, case when calculated type='float' then length(scan(strip(LBORRES),2,'.')) else . end as sigdig, case when calculated type='float' then (strip(put(length NOTE: Line generated by the CALL EXECUTE routine. 4 +(LBORRES),best.)) ||"."||strip(put(calculated sigdig,best.)),best.) else . end as format - 22 76 4 !+from Sdtmdev.LB group by LBCAT,LBSCAT,LBTESTCD,LBTEST; quit; ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, ), *, **, +, -, /, <, <=, <>, =, >, >=, ?, AND, BETWEEN, CONTAINS, EQ, EQT, GE, GET, GT, GTT, IN, IS, LE, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, ^, ^=, |, ||, ~, ~=. ERROR 76-322: Syntax error, statement will be ignored. 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.00 seconds
Can you please look into log and suggest something to resolve flagged errors? Thanks in advance!
You cannot assign a character value in one WHEN and a numeric value (the missing value of .) in the next WHEN. Both WHEN must assign a character value or both WHEN must assign a numeric value.
The string
,best.
where the error is indicated is invalid, it appears to be part he STRIP() function from the line above, and it doesn't belong there because STRIP() does not use a 2nd argument.
+ proc sql noprint; 1 + create table test1 as select distinct LBTESTCD as testcd length=8, "LB" as dataset length=8,"LBCAT" as catvar length=8,"LBSCAT" as scatvar length=8,"LBTESTCD" as testvar length=8,"LBORRES" as resultvar length=8,LBCAT as cat 2 + length=200,LBSCAT as scat length=200,LBTEST as test length=40, max(length(strip(LBORRES))) as length, case when max(compress(LBORRES)) eq ' ' then 'All missing' when compress(LBORRES,'1234567890') eq '.' then 'float' when compress(LBORRES,'1234567890') 3 + eq ' ' then 'integer' when input(LBORRES,anydtdte12.) ne . then 'datetime' else 'text' end as type, case when calculated type='float' then length(scan(strip(LBORRES),2,'.')) else . end as sigdig, case when calculated type='float' then strip(put(length 4 +(LBORRES),best.)) ||"."||(strip(put(calculated sigdig,best.))) else . end as format from Sdtmdev.LB group by LBCAT,LBSCAT,LBTESTCD,LBTEST; ERROR: Result of WHEN clause 2 is not the same data type as the preceding results. 4 + quit; NOTE: The SAS System stopped processing this step because of errors. NOTE: PROCEDURE SQL used (Total process time): real time 0.03 seconds cpu time 0.01 seconds
When I change code as per suggestion, I am diving into another code error. Can you please guide me on this?
You cannot assign a character value in one WHEN and a numeric value (the missing value of .) in the next WHEN. Both WHEN must assign a character value or both WHEN must assign a numeric value.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.