|
Seems like the easy solution would be option SERROR. But I don't know
how that "fits in" with the EG code generator.
961 options serror=0;
962 PROC FORMAT LIB=WORK;
963 VALUE $tmp "p&p" = "Post and Packing";
NOTE: Format $TMP has been output.
964 run;
NOTE: PROCEDURE FORMAT used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
965 options serror=1;
On Fri, Feb 11, 2011 at 11:08 AM, DUELL, BOB (ATTCINW) <BD9439@att.com> wrote:
> No, using "p&&p" would not work.
>
> The Enterprise Guide feature Andy is describing is a "code generator"
> for PROC FORMAT. The user is presented a "form" into which he types a
> format RANGE and a LABEL. The format range must match exactly what his
> data looks like (in this case, a three-character string "p&p" without
> the quotes).
>
> So, the form looks like this (values to the right typed by the user):
>
> LABEL: Post and Packing
> RANGE: p&p
>
> EG generates the following code (WORK library and $tmp names were also
> on the form):
>
> PROC FORMAT LIB=WORK;
> VALUE $tmp
> "p&p" = "Post and Packing";
> RUN;
>
> The problem is that because the strings are enclosed in double-quotes,
> they get scanned by the macro processor. In this case, it sees what it
> thinks is a macro variable "p" and attempts to insert that value into
> the string.
>
> Note that the only reason he got a warning was because the macro
> variable "p" did not already exist. But if it HAD existed, SAS would
> have happily done the symbol substitution without any warning. That
> would certainly have not been what was wanted and could have created an
> error extremely hard to diagnose.
>
> The more I think about it the more hesitant I am to use the code
> generating aspects of EG, unless one can save all the code and manually
> edit it somehow. But I'm just getting started with EG myself (old dog,
> new trick).
>
> Bob
>
>
> -----Original Message-----
> From: Bolotin Yevgeniy [mailto:YBolotin@schools.nyc.gov]
> Sent: Friday, February 11, 2011 8:38 AM
> To: DUELL, BOB (ATTCINW)
> Subject: RE: Re: Enterprise Guide - Code generator in Create Format -
> bug & solution
>
> Just out of curiousity (i don't have access to SAS Enterprise) -
> wouldn't just using "p&&p" work?
>
>
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
> DUELL, BOB (ATTCINW)
> Sent: Friday, February 11, 2011 11:09 AM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Re: Enterprise Guide - Code generator in Create Format - bug &
> solution
>
> Hi,
>
> This is a good tip; I'm sure I'll run into this as I start using EG more
> and more.
>
> If you still have the ear of someone at SAS, I'd suggest that a better
> "fix" is that the Code Generator should never use double-quotes as
> string delimiters. Although I can imagine some cases where macro
> variable resolution might be useful, I think that would be very rare.
>
> Thanks for reporting this!
>
> Bob
>
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
> Andy Bolton
> Sent: Friday, February 11, 2011 4:15 AM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Enterprise Guide - Code generator in Create Format - bug &
> solution
>
> Thought I'd share a bug/solution found in Enterprise Guide 4.1 this
> week,
> apologies if been covered before.
>
> We've a data field which contains the a 3 char value, eg aaa, bbb, and
> then a problem one - p&p
>
> When using the
>
> Task -> Data -> Create Format
>
> and then doing
>
> New Label - Post and Packing
> New Range -> Discrete -> p&p
>
> then
>
> Run
>
> You get a warning, as the Create Format code generator automatically
> creates the format code as
>
> proc format lib=work;
> value $formatname
> "p&p" = "Post and Packing"
> ;
> run;
>
> Therefore - when the Format actually runs you get a warning, as the "
> and
> & interact, and SAS goes off merrily looking for a macro &p to resolve,
> which of course doesn't exist.
>
> Unfortunately the Code Generator from Create Format is one of the ones
> you
> can't edit, so you can't go in and change the " "s to ' 's.
>
> But - there is a work around.
>
> instead of
>
> New Range -> Discrete -> and entering p&p
>
> you can do
>
> New Range -> Discrete -> you can enter
>
> %nrstr(p&p)
>
> as the variable.
>
> the code runs without a warning, and the generated code is
>
> proc format lib=work;
> value $formatname
> "%nrstr(p&p)" = "Post and Packing"
> ;
> run;
>
> Now, that's good if you know about macro-masking, but I'm not convinced
> that most EG folk would know that.
>
> So I've asked for it to be added as a R&D development that there's
> a "suppress double quote" check box or similar for the code generator,
> or
> that you can go in and edit the code.
>
> Sorry if this has all be been covered before, but I did have a look and
> couldn't find it.
>
> Cheers,
>
> Andy
>
>
> AndyBolton@kokino-marvo.com | kokino-marvo ltd: Strategy, Analytics &
> Modelling
>
|