BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Harsh11387
Calcite | Level 5
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!

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
Harsh11387
Calcite | Level 5
 + 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?

PaigeMiller
Diamond | Level 26

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.

--
Paige Miller

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 3 replies
  • 868 views
  • 0 likes
  • 2 in conversation