BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Phil_NZ
Barite | Level 11

Hi all SAS Users, 

 

I saw the difference in SAS order of code written and from the log as be low

My code

data filter;
	set var_cal;
	where (n(ajexdi,prccd_abs_,trfd)=3 or n(prccd_abs_,prchd,prcld)=3)
		and
		prccd_abs_ > 0
		and
		tpci='0'
		and
		(prcstd=3 or (prcstd=4 and LOC='CAN') or prcstd=10)
		and
		(input(SIC, 4.) not in (4900:4949, 6000:6999))
		and
		(raw_return<200)
	;
run;

The log is as below

NOTE: There were 20150398 observations read from the data set WORK.VAR_CAL.
      WHERE ((N(ajexdi, prccd_abs_, trfd)=3) or (N(prccd_abs_, prchd, prcld)=3)) and (prccd_abs_>0) and (tpci='0') and (prcstd in 
      (3, 10) or ((prcstd=4) and (LOC='CAN'))) and (raw_return<200) and ((INPUT(SIC, 4.) not = INT(INPUT(SIC, 4.))) or  not 
      ((INPUT(SIC, 4.)>=4900 and INPUT(SIC, 4.)<=4949) or (INPUT(SIC, 4.)>=6000 and INPUT(SIC, 4.)<=6999)));

As we can see from the code, raw_return <200 is at the last condition while in the log, the raw_return condition is not the last condition, it is quite strange to me.

Could you please help me to sort it out?

 

Warm regards.

 

 

 

Thank you for your help, have a fabulous and productive day! I am a novice today, but someday when I accumulate enough knowledge, I can help others in my capacity.
1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

There is nothing wrong with the WHERE statement in the log. The reason for the reordering is SAS has to interpret your use of ranges -  (4900:4949, 6000:6999) so has chosen to put the translation at  the end of the WHERE. The order of the WHERE components won't affect the result. 

View solution in original post

2 REPLIES 2
SASKiwi
PROC Star

There is nothing wrong with the WHERE statement in the log. The reason for the reordering is SAS has to interpret your use of ranges -  (4900:4949, 6000:6999) so has chosen to put the translation at  the end of the WHERE. The order of the WHERE components won't affect the result. 

Reeza
Super User
In general, SAS optimizes your code for processing and that's what you're seeing there. You'll often see notes such as "Interpreted mean as means". You can look at the SAS options for controlling what you see in the log - MSGLEVEL is one option, there are others.

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