| Date: | Thu, 2 Apr 2009 08:37:37 -0400 |
| Reply-To: | Jack Clark <jclark@HILLTOP.UMBC.EDU> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Jack Clark <jclark@HILLTOP.UMBC.EDU> |
| Subject: | Re: proc sql; |
|
| In-Reply-To: | <583d10d00904020527t20cf1268s336047a5a4559245@mail.gmail.com> |
| Content-Type: | text/plain; charset="us-ascii" |
If I understand your explanation correctly, you want a summarization of
your data, by ITEM, with DEMAND1 representing the number of observations
where the DEMAND for that item is 0. Is that correct?
If so, I think the following SQL code will do.
data have;
infile cards missover;
input item $ demand;
cards;
A 0
B 1
A 5
B 2
;
run;
proc sql;
select item, sum(case when demand = 0 then 1 else 0 end) as demand1
from have
group by item
;
quit;
Jack
Jack Clark
Senior Research Analyst
phone: 410-455-6256
fax: 410-455-6850
jclark@hilltop.umbc.edu ________________________________
From: mahesh kumar peesari [mailto:peesari.mahesh@gmail.com]
Sent: Thursday, April 02, 2009 8:27 AM
To: Jack Clark
Subject: Re: proc sql;
HI Jack,
Actually i have dataset with 12000 observations and columns it has are
date(month wise),item and demand.so my requirement is whenever the the
demand is 0,i want to club the demand when zero accordingly to the item
i can do it,but my distinct item no.s are 5000 when i run this query..
proc sql;
create table asdf as select distinct(item),count(demand)
from Examples.as group by lptno where demand=0 ;
quit;
i am getting my output with distinct item no of 4843 because
of the where condition but i still want the remaining item
whose demand is not zero in my new data set.
Thanks
On Thu, Apr 2, 2009 at 5:51 PM, Jack Clark <jclark@hilltop.umbc.edu>
wrote:
Joe,
What are you trying to do to the data to get the desired output? How is
DEMAND1 created?
Jack
Jack Clark
Senior Research Analyst
phone: 410-455-6256
fax: 410-455-6850
jclark@hilltop.umbc.edu
University of Maryland, Baltimore County
Sondheim Hall, 3rd Floor
1000 Hilltop Circle
Baltimore, MD 21250
Confidentiality Notice: This e-mail may contain information that is
legally privileged and that is intended only for the use of the
addressee(s) named above. If you are not the intended recipient, you are
hereby notified that any disclosure, copying of this e-mail,
distribution, or action taken in reliance on the contents of this e-mail
and/or documents attributed to this e-mail is strictly prohibited. If
you have received this information in error, please notify the sender
immediately by phone and delete this entire e-mail. Thank
you.-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
SUBSCRIBE SAS-L Joe H. Smith
Sent: Thursday, April 02, 2009 8:16 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: proc sql;
Hi all;
i have data like this...
item demand
A 0
B 1
A 5
B 2
I want my output like this
item demand1
A 1
B 0
i have tried using proc sql but i cant do this...
can an yone of you help me please..
Thanks & regards
--
Jack Off All Trades....But Master Of None...
|