BookmarkSubscribeRSS Feed
Ronein
Meteorite | Level 14

Hello

There is an error in this code that create format.

What is the way to solve it?

 

proc format;
value Fmt
-999='(a) A=0 AND B not 0'
-888='(b) A=0 AND B=0'
-777='(c)  B=0 AND A not 0'
0='(d) A>0 AND B=0'
0<-25='(e1) Ratio till 25%'
25<-50='(e2) 25%<Ratio<=50%'
50<-75='(e3) 50%<Ratio<=75%'
75<-85='(e4) 75%<Ratio<=85%'
85<-95='(e5) 85%<Ratio<=95%'
95<100='(e6) 95%<Ratio<100%'
100='(e7) Ratio=100%'
100<-105='(f1) 100%<Ratio<=105%'
105<-115='(f2) 105%<Ratio<=115%'
115<-125='(f3) 115%<Ratio<=125%'
125<-150='(f4) 125%<Ratio<=150%'
150<-HIGH='(f5) 150%+'
other='(g) Negative Ratio'
;
Run;

error 

1                                                          The SAS System                                 10:31 Monday, May 27, 2024

1          ;*';*";*/;quit;run;
2          OPTIONS PAGENO=MIN;
3          %LET _CLIENTTASKLABEL='Program (2)';
4          %LET _CLIENTPROCESSFLOWNAME='Process Flow';
5          %LET _CLIENTPROJECTPATH='';
6          %LET _CLIENTPROJECTPATHHOST='';
7          %LET _CLIENTPROJECTNAME='';
8          %LET _SASPROGRAMFILE='';
9          %LET _SASPROGRAMFILEHOST='';
10         
11         ODS _ALL_ CLOSE;
12         OPTIONS DEV=PNG;
13         GOPTIONS XPIXELS=0 YPIXELS=0;
14         FILENAME EGSR TEMP;
15         ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
16             STYLE=HTMLBlue
17             STYLESHEET=(URL="file:///C:/Program%20Files/SASHome/SASEnterpriseGuide/7.1/Styles/HTMLBlue.css")
18             NOGTITLE
19             NOGFOOTNOTE
20             GPATH=&sasworklocation
21             ENCODING=UTF8
22             options(rolap="on")
23         ;
NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
24         
25         GOPTIONS ACCESSIBLE;


26         proc format;
27         value Fmt
28         -999='(a) A=0 AND B not 0'
29         -888='(b) A=0 AND B=0'
30         -777='(c)  B=0 AND A not 0'
31         0='(d) A>0 AND B=0'
32         0<-25='(e1) Ratio till 25%'
33         25<-50='(e2) 25%<Ratio<=50%'
34         50<-75='(e3) 50%<Ratio<=75%'
35         75<-85='(e4) 75%<Ratio<=85%'
36         85<-95='(e5) 85%<Ratio<=95%'
37         95<100='(e6) 95%<Ratio<100%'
              ___
              22
              76
ERROR 22-322: Syntax error, expecting one of the following: ',', -.  

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

38         100='(e7) Ratio=100%'
39         100<-105='(f1) 100%<Ratio<=105%'
40         105<-115='(f2) 105%<Ratio<=115%'
41         115<-125='(f3) 115%<Ratio<=125%'
42         125<-150='(f4) 125%<Ratio<=150%'
43         150<-HIGH='(f5) 150%+'
44         other='(g) Negative Ratio'
45         ;
NOTE: The previous statement has been deleted.
46         Run;

2                                                          The SAS System                                 10:31 Monday, May 27, 2024

NOTE: PROCEDURE FORMAT used (Total process time):
      real time           0.00 seconds
      user cpu time       0.01 seconds
      system cpu time     0.00 seconds
      memory              73.81k
      OS Memory           27300.00k
      Timestamp           05/28/2024 07:26:06 AM
      Step Count                        157  Switch Count  0
      Page Faults                       0
      Page Reclaims                     7
      Page Swaps                        0
      Voluntary Context Switches        3
      Involuntary Context Switches      1
      Block Input Operations            0
      Block Output Operations           0
      
NOTE: The SAS System stopped processing this step because of errors.
47         
48         GOPTIONS NOACCESSIBLE;
49         %LET _CLIENTTASKLABEL=;
50         %LET _CLIENTPROCESSFLOWNAME=;
51         %LET _CLIENTPROJECTPATH=;
52         %LET _CLIENTPROJECTPATHHOST=;
53         %LET _CLIENTPROJECTNAME=;
54         %LET _SASPROGRAMFILE=;
55         %LET _SASPROGRAMFILEHOST=;
56         
57         ;*';*";*/;quit;run;
58         ODS _ALL_ CLOSE;
59         
60         
61         QUIT; RUN;
62         
6 REPLIES 6
Patrick
Opal | Level 21
It’s just missing a dash as used in your other lines.
If you want to include 100 don’t use the angle bracket.
Ronein
Meteorite | Level 14

 

95<100='(e6) 95%<Ratio<100%'
100='(e7) Ratio=100%'

I want that 100 will be a separate group

I want that group 95<100 will be between 95(not included) and 100 (not included)

 

Patrick
Opal | Level 21

95<-100
Add the dash!

Below your format fixed BUT it will likely not return what you're after. Just try with a few values like 100. The format definition will likely some amendment to return the desired label for a specific value.

proc format;
  value Fmt
    -999      ='(a) A=0 AND B not 0'
    -888      ='(b) A=0 AND B=0'
    -777      ='(c)  B=0 AND A not 0'
    0         ='(d) A>0 AND B=0'
    0<-25     ='(e1) Ratio till 25%'
    25<-50    ='(e2) 25%<Ratio<=50%'
    50<-75    ='(e3) 50%<Ratio<=75%'
    75<-85    ='(e4) 75%<Ratio<=85%'
    85<-95    ='(e5) 85%<Ratio<=95%'
    95<-100   ='(e6) 95%<Ratio<100%'
    100       ='(e7) Ratio=100%'
    100<-105  ='(f1) 100%<Ratio<=105%'
    105<-115  ='(f2) 105%<Ratio<=115%'
    115<-125  ='(f3) 115%<Ratio<=125%'
    125<-150  ='(f4) 125%<Ratio<=150%'
    150<-HIGH ='(f5) 150%+'
    other     ='(g) Negative Ratio'
  ;
Run;

Given your label I assume what you really want is for values around 100 (haven't checked the rest):

    95<-<100   ='(e6) 95%<Ratio<100%'
    100       ='(e7) Ratio=100%'
    100<-105  ='(f1) 100%<Ratio<=105%'
Ronein
Meteorite | Level 14

Thanks,

However I don't understand something.

There are 2 groups that 100 is included in their definition

In the group defined by 95<-100 I see dash next to 100.Does it mean that 100 is included?

 

95<-100='(e6) 95%<Ratio<100%'
100='(e7) Ratio=100%'
Patrick
Opal | Level 21

@Ronein I believe what you're really after is what I shared already.

    95<-<100   ='(e6) 95%<Ratio<100%'
    100       ='(e7) Ratio=100%'
    100<-105  ='(f1) 100%<Ratio<=105%

If not 100% if things work as desired then it's also always a good idea to mock-up some sample data for testing. Like 3 rows with values 99, 100, 101 and then test how the formatted values look like.

 

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
  • 6 replies
  • 426 views
  • 5 likes
  • 3 in conversation