BookmarkSubscribeRSS Feed
Armand_B
Calcite | Level 5

**** JOIN CHOLESTEROL AND DOSING DATA INTO ADLB ANALYSIS
**** DATASET AND CREATE WINDOWING VARIABLES;

 

proc sql;
create table ADLB as
select LB.USUBJID, LBDTC, LBTESTCD as PARAMCD,
LBSTRESN as AVAL, EXSTDTC, input(LBDTC,yymmdd10.) as
ADT format=yymmdd10.,
case
    when -5 <= (input(LBDTC,yymmdd10.) – (input(EXSTDTC,yymmdd10.)) <= -1 and
LBSTRESN ne . then 'YES'
else 'NO'
end as within5days
from LB as LB, EX as EX
where LB.USUBJID = EX.USUBJID
order by USUBJID, LBTESTCD, within5days, ADT;
quit;

 

 

PS

this code according to the log file ( see enclosed) has one error in the Case statement

  i m unable to fix it

any hint 

Regards

10 REPLIES 10
PaigeMiller
Diamond | Level 26

Since many of us will not or cannot download files, please copy the log as text and paste it into the window that appears when you click on the </>. To be specific, do not copy the log from your PDF file, copy the log from the log window. This preserves the formatting of the log and makes it easier to read. 

--
Paige Miller
PaigeMiller
Diamond | Level 26

Repeating: "copy the log as text and paste it into the window that appears when you click on the </> icon"

--
Paige Miller
AlexStr
Calcite | Level 5

The problem is with unbalanced brackets

 

( input(LBDTC,yymmdd10.) – ( input(EXSTDTC,yymmdd10.) )

Armand_B
Calcite | Level 5

it  does not  work i tried it

PaigeMiller
Diamond | Level 26

Show us the log. Copy the log as text and paste it into the window that appears when you click on the </> icon.

--
Paige Miller
Armand_B
Calcite | Level 5

i think  i sent you the log file contents already  here it is  :

 


1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
68
69 **** JOIN CHOLESTEROL AND DOSING DATA INTO ADLB ANALYSIS
70 **** DATASET AND CREATE WINDOWING VARIABLES;
71 proc sql;
72 create table ADLB as
73 select LB.USUBJID, LBDTC, LBTESTCD as PARAMCD,
74 LBSTRESN as AVAL, EXSTDTC, input(LBDTC,yymmdd10.) as
75 ADT format=yymmdd10.,
76 case
77 when -5 <= (input(LBDTC,yymmdd10.) – (input(EXSTDTC,yymmdd10.)) <= -1 and
                                                                  ___
                                                                 22
                                                                 76
ERROR 22-322: syntax error,one of the following values is expected : !, !!, &, *, **, +, -, /, <, <=, <>, =, >, >=, ?, AND,
BETWEEN, CONTAINS, EQ, EQT, GE, GET, GT, GTT, LE, LET, LIKE, LT, LTT, NE, NET, OR, ^=, |, ||, ~=.

ERROR 76-322: Syntax error, statement will be ignored.

78 LBSTRESN ne . then 'YES'
79 else 'NO'
80 end as within5days
81 from LB as LB, EX as EX
82 where LB.USUBJID = EX.USUBJID
83 order by USUBJID, LBTESTCD, within5days, ADT;
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
84 quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL a utilisé (Durée totale du traitement) :
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 230.96k
OS Memory 23460.00k
Timestamp 24/08/2021 01:39:19 PM
Step Count 24 Switch Count 0
Page Faults 0
Page Reclaims 58
Page Swaps 0
Voluntary Context Switches 0
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 0

85
86 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
96

PaigeMiller
Diamond | Level 26

We would all benefit if the formatting of the log is maintained. Copy the log as text and paste it into the window that appears when you click on the </> icon. Do not ignore the part in red. From now on, this is mandatory that you present the log this way.

 

It appears you don't have a minus sign where the error is happening, instead you have an "en-dash". Put a minus sign (hyphen) there.

--
Paige Miller
AlexStr
Calcite | Level 5

the symbol  "–" between "input" instructions is wrong. It's from Unicode.

Change it manually to the "-" (minus sign) 

And of cause balance brackets, please

Reeza
Super User
proc sql;
create table ADLB as
select 
LB.USUBJID, 
LBDTC, 
LBTESTCD as PARAMCD,
LBSTRESN as AVAL, 
EXSTDTC, 
input(LBDTC, yymmdd10.) as ADT format = yymmdd10.,
case
    when -5 <= (input(LBDTC, yymmdd10.) - input(EXSTDTC, yymmdd10.)) <= -1 
 and  LBSTRESN ne . then 'YES'
  else 'NO'
 end as within5days
from LB as LB, EX as EX
where LB.USUBJID = EX.USUBJID
order by USUBJID, LBTESTCD, within5days, ADT;
quit;

Does this work?

ballardw
Super User

The log often contains diagnostic characters as in this case, underscores where SAS determined there is a syntax problem. However, the main message windows on this forum reformat pasted text. Which moves the locations of those diagnostic characters making them less helpful.

Which is why we request pasting the log into a text box opened with the </> icon: that will preserve the text as it appears in the log.

 

If you look real close you may see that the character you think is a subtraction symbol is actually a line character. at least that is what I see when I copy your pasted text into my editor. 

Try retyping the – as a -  <=See the difference between the two characters? The second is a subtraction.

 

When you copy and paste text from different sources you may get artifacts like this from files like PDF, RTF, Word processors, and some websites where programming characters get converted into "pretty" text characters for display. But they are not valid in programming syntax.

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 10 replies
  • 1561 views
  • 1 like
  • 5 in conversation