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

I copied this code of a practice question, the question is that value will be assigned to 10, which is seemingly between the "warm" and "hot" temperature ranges.

 

proc format lib=sasuser;
value tempc low< 0 = 'BELOW FREEZING'
0 < 5 = 'COLD'
5 < 10 = 'MILD'
10 < 15 = 'WARM'
15 < high = 'HOT';
run;

Intuitively, it seems that 10 is assigned no format and should be presented just as 10. But not only does the key claim 10 will be presented as "WARM", the code refuses to run on my system! 

 

SAS tells me the "<" signts is not recognized and will be ignored(!).

 

So:

 

Question 1:

 

Why on earth would 10 be presented as 'WARM' and not as 10, is this another typo?

 

Question 2:

 

Why does the code fail to run? I double checked with the advanced programmer's prep guide and this seems to be the way to assign a format to an interval....  

 

asdf

1 ACCEPTED SOLUTION

Accepted Solutions
Jagadishkatam
Amethyst | Level 16

The syntax of the code was incorrect , the correct syntax is as below

 

We create the formats to change the display of the data, if you just want to display the values as is then do not apply the format. The format controls the display of the data.

 

proc format lib=sasuser;
value tempc low -< 0 = 'BELOW FREEZING'
0 -< 5 = 'COLD'
5 -< 10 = 'MILD'
10 -< 15 = 'WARM'
15 - high = 'HOT';
run;
Thanks,
Jag

View solution in original post

3 REPLIES 3
Jagadishkatam
Amethyst | Level 16

The syntax of the code was incorrect , the correct syntax is as below

 

We create the formats to change the display of the data, if you just want to display the values as is then do not apply the format. The format controls the display of the data.

 

proc format lib=sasuser;
value tempc low -< 0 = 'BELOW FREEZING'
0 -< 5 = 'COLD'
5 -< 10 = 'MILD'
10 -< 15 = 'WARM'
15 - high = 'HOT';
run;
Thanks,
Jag
Syntas_error
Quartz | Level 8

So in summary:

 

1. We have to use the "-<"-sign instead of the ""<"-sign when specifying intervals. 

 

2. Forr some unknown reason we can't use an "-<"-sign before "high" but must use the "-"-sign instead?

Jagadishkatam
Amethyst | Level 16
Yes I agree with your understanding.
When we use the words like low or high, it is implicit they refer to lower or higher values hence we do not need the '<' symbol.
Thanks,
Jag

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!

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