BookmarkSubscribeRSS Feed
andrew0845
Calcite | Level 5
What does ([0-9])3 mean in a proc format picture definition?
10 REPLIES 10
Ksharp
Super User
what is your proc format code? and some origin data?


Ksharp
andrew0845
Calcite | Level 5
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
Peter_C
Rhodochrosite | Level 12
> 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........
andrew0845
Calcite | Level 5
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!
data_null__
Jade | Level 19
> 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.
Tim_SAS
Barite | Level 11
Here's some info about how to include program code in your forum post: http://support.sas.com/forums/thread.jspa?messageID=27609毙
andrew0845
Calcite | Level 5
The original code is as follows:

proc format;
picture agegrp
1-<([0-9])3='00 Youth'
13-<([0-9])0='00 Teen'
20-<([0-9])0='00 Adult'
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!
Ksharp
Super User
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
Patrick
Opal | Level 21
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'
    20- <([0-9])0 ='00 Adult'
    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'
    20- < 70 ='00 Adult'
    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
Peter_C
Rhodochrosite | Level 12
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'
20-<([0-9])0='00 Adult'
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'
20-<70='00 Adult'
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'
20-70='00 Adult'
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=20.4 20 Adult 20 Adult
age=20.8 21 Adult 20 Adult
age=21.2 21 Adult 21 Adult
age=21.6 22 Adult 21 Adult
age=22 22 Adult 22 Adult
age=68 68 Adult 68 Adult
age=68.6 69 Adult 68 Adult
age=69.2 69 Adult 69 Adult
age=69.8 70 Adult 69 Adult
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

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 10 replies
  • 1306 views
  • 0 likes
  • 6 in conversation