Date: Wed, 16 Dec 2009 09:45:18 -0500
Reply-To: Chang Chung <chang_y_chung@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Chang Chung <chang_y_chung@HOTMAIL.COM>
Subject: Re: Undesirable output in SAS 9.2
On Tue, 15 Dec 2009 15:44:51 -0800, GNV Resident <sfeone@GMAIL.COM> wrote:
>Hello.
>
>Now I am typing and running all the examples from the book 'SAS
>Advanced Programming in SAS 9'.
>Just now I got the very strange output from the SAS code in page 331.
>If everything is fine, I have to
>get the output with footnote 'Some Fees Are Unpaid'. But, I had the
>output, '&foot'. Very strange!!
>
>My SAS code is given below:
>options symbolgen pagesize=30;
>%let crsnum = 3;
>data revenue;
> set sasuser.all;
> where course_number = &crsnum;
> total = total + 1;
> if paid = 'Y' then paidup + 1;
> if final then do;
> put total= paidup=;
> if paidup < total then do;
> call symput('foot', 'Some Fees Are Unpaid');
> end;
> else do;
> call symput('foot', 'All Students Have Paid');
> end;
> end;
>run;
>
>proc print data=revenue;
> var student_name student_company paid;
> title "Payment Status for Course &crsnum";
> footnote "&foot";
>run;
>
>==================================================
>I do not know what's wrong. If you have any comment, please do for me.
Hi, GNV Resident:
Two things are incorrect: (1) you have to retain total -- one way to do this
is to use the sum statement (total + 1;); (2) you have to create the final
flag that signals the last observation of the input data. I would use end=
option to the set statement.
Below has other simplifications as well, but they are not essential. HTH.
HTH.
Cheers,
Chang
%let crsnum = 3;
%let foot =;
data revenue;
set sasuser.all end = final; /* (2) */
where course_number = &crsnum;
total + 1; /* (1) */
paidup + (paid = 'y');
if final then do;
length msg $40;
msg = ifc(paidup < total,
"Some Fees Are Unpaid",
"All Students Have Paid");
call symputx('foot', trim(msg), G);
end;
run;
proc print data=revenue;
var student_name student_company paid;
title "Payment Status for Course &crsnum";
footnote "&foot";
run;
/* on lst
Obs Student_Name Student_Company Paid
1 Bills, Ms. Paulette Reston Railway Y
2 Chevarley, Ms. Arlene Motor Communications N
3 Clough, Ms. Patti Reston Railway N
4 Crace, Mr. Ron Von Crump Seafood Y
5 Davis, Mr. Bruce Semi;Conductor Y
6 Elsins, Ms. Marisa F. SSS Inc. N
7 Gandy, Dr. David Paralegal Assoc. Y
8 Gash, Ms. Hedy QA Information Systems Center Y
9 Haubold, Ms. Ann Reston Railway Y
10 Hudock, Ms. Cathy So. Cal. Medical Center Y
11 Kimble, Mr. John Alforone Chemical N
12 Kochen, Mr. Dennis Reston Railway Y
13 Larocque, Mr. Bret Physicians IPA Y
14 Licht, Mr. Bryan SII Y
15 McKnight, Ms. Maureen E. Federated Bank Y
16 Scannell, Ms. Robin Amberly Corp. N
17 Seitz, Mr. Adam Lomax Services Y
18 Smith, Ms. Jan Reston Railway N
19 Sulzbach, Mr. Bill Sailbest Ships Y
20 Williams, Mr. Gene Snowing Petroleum Y
Some Fees Are Unpaid
*/
|