Calcite | Level 5

## proc format;

What does ([0-9])3 mean in a proc format picture definition?
10 REPLIES 10
Super User

## Re: proc format;

what is your proc format code? and some origin data?

Ksharp
Calcite | Level 5

## Re: proc format;

proc format;
picture agegrp
1-<([0-9])3='00 Youth'
13-<([0-9])0='00 Teen'
run;

I don't understand what "([0-9])3" and "([0-9])0" mean. Thanks.

Andrew
Rhodochrosite | Level 12

## Re: proc format;

> proc format;
> picture agegrp
> 1-<([0-9])3='00 Youth'
> 13-<([0-9])0='00 Teen'
> un;
>
> don't understand what "([0-9])3" and "([0-9])0"
> mean. Thanks.
>
> Andrew

Looks like some form of regular expression........
Calcite | Level 5

## Re: proc format;

It's just because I cannot "cut and paste" the whole code. I don't know where the wrong is. Whenever, I cut and paste the posted message is just part of the original message I intended to post!

The part posted is the part I don't understand. The other part, you can imagine, is just like a normal definition for a proc format picture.

I don't undertand the following way to express a range for a value in a picture definition.

I just show the uplimit of a range for a value: ([0-9])3, say.

Does that mean 0*3, 1*3..., 9*3 or 3, 4,..., 93? What does that really mean?

Would you please tell me how I can understand that? Thanks!

## Re: proc format;

> The part posted is the part I don't understand. The
> other part, you can imagine, is just like a normal
> definition for a proc format picture.

If we could see the code in context it might make sense. Otherwise it is just a string of characters.
Barite | Level 11

## Re: proc format;

Calcite | Level 5

## Re: proc format;

The original code is as follows:

proc format;
picture agegrp
1-<([0-9])3='00 Youth'
13-<([0-9])0='00 Teen'
70-high='000 Senior';
run;

< is the symbol for "smaller than". That is the way I can input the original code, otherwise, the most of part will disappear mysteriously after it is posted.

What does ([0-9])3 and ([0-9])0 mean in the picture definition?

Besides, if I only use < not -<, what would happend? Inclusive for the lower limit or upper limit?

Thanks!
Super User

## Re: proc format;

Sorry.I do not have some clue.I have never see this code before. It looks like so weird.
Maybe You need to google it or check some documentation.

Ksharp
Opal | Level 21

## Re: proc format;

Hi

I don't think the code you've posted is valid SAS syntax.

At least when I run the following I'm getting a syntax error.

proc format;
picture agegrp
1- <([0-9])3 ='00 Youth'
13- <([0-9])0 ='00 Teen'
70- high ='000 Senior'
;
run;

Below code is valid SAS syntax and probabely gives you what you're after:

proc format;
picture agegrp
low-< 1 ='00 Baby'
1- < 13 ='00 Youth'
13- < 20 ='00 Teen'
70- high ='000 Senior'
;
run;

And: The SAS Forum pages have an issue with < and > These are characters used in HTML to mark the start and end of a HTML tag.
To use < and > in a post you have to write them in HTML syntax (HTML encoding). To do so you have to add a ';' after '<' and '>'.

HTH
Patrick Message was edited by: Patrick
Rhodochrosite | Level 12

## Re: proc format;

Patrick
one big reason I go to SASGF is the access to people who make SAS what it is!
In SASGF in April this year the man who makes the formats was presenting a glimpse of syntax a little similar to what Andrew0845 posted. Rick demonstrated using regular expression syntax in an informat to parse strings in the magic way of perl regular expressions. He has been working on it for a few years so it is good to hear that it will finally be delivered in SAS9.3 (some time soon, qtr3 2011, maybe 😉
Hence my earlier posting suggesting that regular expressions might have been behind the origins of "([0-9])".
However,
1-<([0-9])3='00 Youth'
13-<([0-9])0='00 Teen'
70-high='000 Senior';
looks more like a weak effort to achieve the ranges in the following test
proc format ;
picture agedesc (round)
1-<13='00 Youth'
13-<20='00 Teen'
70-high='000 Senior';
run ;
%put %sysfunc( putn( 13, agedesc )) %sysfunc( putn( 103, agedesc ));
produces the logline
13 Teen 103 Senior

Interestingly, as these ranges are simply consecutive, PROC FORMAT would assume the choice Andrew's predecessor was enforcing - where consecutive ranges coincide on a value, assume it belongs to the upper range.
picture agede5c
1-13='00 Youth'
13-20='00 Teen'
70-high='000 Senior';
achieves the same effect

data demo ;
do age= 0 to 3, 11.5 to 14 by 3, 18 to 22 by .4, 68 to 72 by .6, 99 to 102 by .7;
put age= age agedesc. age agede5c. ;
end;
stop ;
run;
produced these log lines[pre]age=0 0 0
age=1 1 Youth 1 Youth
age=2 2 Youth 2 Youth
age=3 3 Youth 3 Youth
age=11.5 12 Youth 11 Youth
age=18 18 Teen 18 Teen
age=18.4 18 Teen 18 Teen
age=18.8 19 Teen 18 Teen
age=19.2 19 Teen 19 Teen
age=19.6 20 Teen 19 Teen
age=20 20 Teen 20 Teen
age=70.4 70 Senior 70 Senior
age=71 71 Senior 71 Senior
age=71.6 72 Senior 71 Senior
age=99 99 Senior 99 Senior
age=99.7 100 Senior 99 Senior
age=100.4 100 Senior100 Senior
age=101.1 101 Senior101 Senior
age=101.8 102 Senior101 Senior[/pre]
peterC
Discussion stats
• 10 replies
• 1306 views
• 0 likes
• 6 in conversation