Date: Wed, 3 Sep 2003 14:44:13 -0400
Reply-To: Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Subject: Re: missing values
Content-Type: text/plain; charset=US-ASCII
Ian is right about the "missing values generated" message appearing (at
least in V. 8.2). My test code:
data _null_;
Inc=sum( 0, rev, -exp ) ;
put _all_;
run;.
What's strange is that the message should not appear, because in fact
no missing values are generated. Including a zero among the arguments to
the SUM function assures that.
>>> Ian Whitlock <WHITLOI1@WESTAT.com> 09/03/03 02:10PM >>>
Howard,
The reason for the conditional testing was to avoid a "missing values
generated" message on the log. While harmless in this case, I still
tend to
look on that message as an indication of a questionable programmer
(yourself
excepted!), since the programmer who accepts such messages probably
doesn't
pay attention to them when they are important.
IanWhitlock@westat.com
-----Original Message-----
From: Howard Schreier [mailto:Howard_Schreier@ITA.DOC.GOV]
Sent: Tuesday, September 02, 2003 5:50 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: missing values
I agree regarding multiple records. Either aggregate first, or use SET
rather than MERGE and include code to aggregate REV and EXP
separately.
With one record per department, I think an unconditional
Inc=sum( 0, rev, -exp ) ;
should be adequate.
As to the formatting, I suggest
proc format;
value blankmv .=' ' other = [best12.];
run;
Then, in the DATA step:
Format rev exp blankmv. inc negparen.;
On Tue, 2 Sep 2003 13:46:04 -0400, Ian Whitlock <WHITLOI1@WESTAT.COM>
wrote:
>Mai,
>
>With one record per department (as your data shows) try
>
>data w ;
> Merge rev exp;
> By dept;
> if missing (exp) then inc = sum ( 0 , rev ) ;
> else
> Inc=sum( 0, rev, -exp ) ;
> Format inc comma9.2;
>run ;
>
>To handle multiple records per department, I would avoid the merge
>issues
by
>summing the revenues and expenditures to one record per department
>first
and
>then using the above code.
>
>IanWhitlock@westat.com
>
>-----Original Message-----
>From: Mai To [mailto:Mai.To@UTH.TMC.EDU]
>Sent: Tuesday, September 02, 2003 11:54 AM
>To: SAS-L@LISTSERV.UGA.EDU
>Subject: missing values
>
>
>I have these two datasets:
>
>1.
>Dept rev
>001 100
>002 200
>003 250
>005 100
>
>
>2.
>Dept exp
>001 80
>003 200
>004 60
>007 50
>
>The result should look like this
>
>Dept rev exp inc
>001 100 80 20
>002 200 200
>003 250 200 50
>004 60 (60)
>005 100 100
>007 50 (50)
>
>These are my codes:
>
>Step1;
>Merge rev exp;
> By dept;
> If rev=' ' then rev=.;
> If exp=' ' then exp=.;
>
>Proc sort data=step1;
>By dept;
>
>Step2;
>Set step1;
>By dept;
>Retain inc;
>Format inc comma9.2;
>If first.dept then inc=0;
> Inc=rev-exp;
>If last.dept and inc ne 0 then output;
>
>
>With the above codes, I received the message "missing values...."
What
>should I do so the "missing values" thing would disappear?
>
>Thanks,
>Mia