[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sas-l
Subject:    Re: Correct version RE: set, nobs=, stop ?
From:       Fried Egg <friedegg2012 () GMAIL ! COM>
Date:       2013-06-28 18:06:52
Message-ID: CANS8eEhtSuks1dOc8WzuiQLo91i877utYtfqwYXGS8FjPd94Sw () mail ! gmail ! com
[Download RAW message or body]

Besides the conversion, symputx also strips the data and macro variable
name of leading and trailing spaces.


On Fri, Jun 28, 2013 at 1:51 PM, Jack Hamilton <jfh@alumni.stanford.edu>wrote:

> I *do* mind seeing conversion messages in the log.  They make it harder to
> spot a real error.
>
> As you say, SYMPUTX is the way to go in this case.
>
> Some or all of the CATT functions also perform messageless implicit
> conversions, which makes them a simpler alternative to code like
> trim(put(a, best.)) || trim(put(p, best.)) etc.
>
>
> On Jun 28, 2013, at 03:39 , Rick Wicklin <Rick.Wicklin@SAS.COM> wrote:
>
> > I want to call attention to something that Jim did in his DATA step,
> > namely convert Nrecords to a character value (using STRIP and PUT) before
> > creating the macro variable.  As many of you know, the SAS DATA step
> > automatically coerces numerical values to character values in certain
> > circumstances. Given that fact, you could also write
> > CALL SYMPUT ('NofCases', Nrecords);
> > if you don't mind seeing a note in the Log that says
> > NOTE: Numeric values have been converted to character values
> >
> > An alternative is to use SYMPUTX instead of SYMPUT, which saves a few
> > keystrokes:
> > CALL SYMPUTX ('NofCases', Nrecords); * macro value;
> > You can also use SYMPUTX in areas of SAS that do NOT automatically coerse
> > numeric to character. For an explanation and example, see
> > http://blogs.sas.com/content/iml/2011/10/17/does-symput-work-in-iml/
> > or short URL http://bit.ly/pZqHZo
> >
> > Rick Wicklin
> > Statistical programming blog: http://blogs.sas.com/content/iml
> >
> > -----------
> > On Thu, 27 Jun 2013 08:51:20 -0400, Jim Groeneveld <jim.1stat@YAHOO.COM>
> > wrote:
> >
> >> Hi friends,
> >>
> >> The most (?) efficient way to obtain the number of observations
> >> in a dataset via that line of code, without the need to read
> >> the entire dataset is to get the NOBS during compilation time:
> >>
> >> DATA _NULL_;
> >> IF 0 THEN SET Dataset NOBS=Nrecords; * do not read data at all;
> >> CALL SYMPUT ('NofCases', STRIP(PUT(Nrecords, BEST.))); * macro value;
> >> STOP; * Otherwise one record would be "output" to _NULL_;
> >> RUN;
> >>
>
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic