Date: Tue, 24 Apr 2007 17:42:20 -0400
Reply-To: Mike Rhoads <RHOADSM1@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Mike Rhoads <RHOADSM1@WESTAT.COM>
Subject: Re: PUTLOG is more like ERROR statement than PUT statement
In-Reply-To: <7367b4e20704241405w75f572fi99855b3f815fab86@mail.gmail.com>
Content-Type: text/plain; charset="us-ascii"
Well, you certainly read the documentation closer than I did. I had
assumed that the 3 statements were equivalent except for the destination
and the setting of _ERROR_. (Of course, they say never to assume ...)
I am particularly chagrined because I passed this assumption on to
numerous innocent victims.
OTOH, I tried a couple other "reasonable" PUT statement constructs (from
the examples in the PUT documentation) with PUTLOG, and they all worked.
I suspect that things like moving up and down within a "page" might not,
but I really don't care about that. So, I still have some optimism that
they were really intended to work basically the same, and someone just
missed the fact that starting with a ( would be treated as an array
reference.
Two other interesting notes:
putlog '' (_all_) (=);
results in
'Name=Alfred
A couple other SAS statements behave this way.
and
putlog ' ' +(-1) (_all_) (=);
although clunky, pretty much provides a complete workaround.
Mike Rhoads
Westat
RhoadsM1@Westat.com
-----Original Message-----
From: owner-sas-l@listserv.uga.edu [mailto:owner-sas-l@listserv.uga.edu]
On Behalf Of data _null_;
Sent: Tuesday, April 24, 2007 5:05 PM
To: Mike Rhoads
Cc: SAS-L List
Subject: Re: PUTLOG is more like ERROR statement than PUT statement
The documentation states
Comparisons
The PUTLOG statement is similar to the ERROR statement except that
PUTLOG does not set _ERROR_ to 1.
See Also
Statement:
ERROR Statement
Although the ERROR statement implies that is like the PUT statement.
Details
The ERROR statement sets the automatic variable _ERROR_ to 1 and,
optionally, writes a message that you specify to the SAS log. When
_ERROR_ = 1, SAS writes the data lines that correspond to the current
observation in the SAS log.
Using ERROR is equivalent to using these statements in combination:
an assignment statement setting _ERROR_ to 1
a FILE LOG statement
a PUT statement (if you specify a message)
another FILE statement resetting FILE to any previously specified
setting.
I don't think anything would be gained by calling it a bug.
On 4/24/07, Mike Rhoads <RHOADSM1@westat.com> wrote:
> It certainly wasn't obvious to me. I had assumed that PUTLOG was
> identical to PUT, except that the output always went to the log.
>
> Have you reported this to Tech Support? I suspect that this might
have
> been an oversight on their part, which hopefully could be fixed
without
> too much trouble.
>
> Mike Rhoads
> Westat
> RhoadsM1@Westat.com
>
> -----Original Message-----
> From: owner-sas-l@listserv.uga.edu
[mailto:owner-sas-l@listserv.uga.edu]
> On Behalf Of data _null_;
> Sent: Tuesday, April 24, 2007 2:13 PM
> To: SAS-L List
> Subject: PUTLOG is more like ERROR statement than PUT statement
>
>
> It is probably obvious to all except me.
>
>
> 52 data _null_;
> 53 set sashelp.class(keep=name obs=1);
> 54 putlog (_all_) (=);
> -
> 22
> 76
> ERROR: Undeclared array referenced: putlog.
> ERROR: Cannot use _all_ as a variable name.
> 55 error (_all_) (=);
> -
> 22
> 76
> ERROR: Undeclared array referenced: error.
> ERROR: Cannot use _all_ as a variable name.
> ERROR 22-322: Syntax error, expecting one of the following: +, =.
> ERROR 76-322: Syntax error, statement will be ignored.
> 56 run;
>
> NOTE: The SAS System stopped processing this step because of errors.
> 57
> 58 data _null_;
> 59 set sashelp.class(keep=name obs=1);
> 60 put (_all_) (=);
> 61 run;
>
> Name=Alfred
> NOTE: There were 1 observations read from the data set SASHELP.CLASS.
> 62
> 63 data _null_;
> 64 set sashelp.class(keep=name obs=1);
> 65 putlog 'NOTE: ' (_all_) (=);
> 66 error 'ERROR:' (_all_) (=);
> 67 run;
>
> NOTE: Name=Alfred
> ERROR:Name=Alfred
> Name=Alfred _ERROR_=1 _N_=1
> NOTE: There were 1 observations read from the data set SASHELP.CLASS.
>