|
Mark ,
I said it shouldnt be done, not that it should never be done. Your point 1
and 2 are valid I will concede those points, some times you just have to do
what the boss and/or client wants, been there done that. On the otherhand
(geez I sound like Daivd) it still doesnt mean it should be done that way,
it is just the programmer has no choice in the decision. If it is just
because a person thinks it will make their life easier or they dont know any
other way then a redesign of the code or rethinking of their process is in
order. Which is the point I was making albiet probably not nearly as clear
as I should have.
Now the call execute thingy might or might not work. Depends on the number
of discrete values which will have to be muliplied by no less than three (
number of lines of code to subset the data one time ). This could put too
much on the stack and SAS will poop out. Or one could wrap the three lines
of code into a macro and use call execute delaying the macro execution until
it is popped off of the stack ( one line of code for each descrete value) if
it is more than SAS can handle SAS will poop out again. Or one could
simply write the code to a file and %include that back into the program.
All I can say is I am sure glad as hell I dont have to mess around with 200
datasets for one project, the nightmares alone would keep me up late at
night.
Toby Dunn
Quickly, bring me a beaker of wine, so that I may wet my mind and say
something clever.
Aristophanes
Wise people, even though all laws were abolished, would still lead the same
life.
Aristophanes
You should not decide until you have heard what both have to say.
Aristophanes
From: "Terjeson, Mark" <Mterjeson@RUSSELL.COM>
Reply-To: "Terjeson, Mark" <Mterjeson@RUSSELL.COM>
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: Creating multiple datasets from one dataset based on value of
a single variable
Date: Tue, 14 Nov 2006 10:09:48 -0800
Hi Toby,
We can't always know the background and objectives.
Normally I don't comment on different viewpoints
of why someone wants to do something, and many of
us have frequently shared this facet numerous times
regarding keeping things normalized instead of
breaking into many separate files. However, there
are three issues that may prompt such a desire. The
first two are 1) the boss said to, 2) the recipient
of the data requested that format. The third,
3) since Mike mentioned millions of rows, it just may
actually prove more effective and efficient in their
environment to process and deal with smaller chunks.
Just as is, or they may have applications that work
with the data selectively and smaller chunks is just
plain faster. Who knows. So we'll arm them with
the best design information and arm them with code
to break it up, and they will have to apply the best
decisions. Your idea of shouldn't be done usually
applies and once I had only a total of a few hundred
records and even after sharing recommendations, the
boss said "that's what the customer wants" and it
was my job to say "Okay". :o)
Hope this is helpful.
Mark Terjeson
Senior Programmer Analyst, IM&R
Russell Investment Group
Russell
Global Leaders in Multi-Manager Investing
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
toby dunn
Sent: Tuesday, November 14, 2006 9:48 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: Creating multiple datasets from one dataset based on value
of a single variable
Mike ,
The reason you are having such a hard time finding a post along this
lines is because it shouldnt be done ( by the way there are a few out
there) . By breaking your data into so many little parts all you will
accomplish is to east up space on your hard drive and make you life as
well as others infinitly more complicated by making yoru code more
complicated to write, understand, debug, and modify. Now I have no clue
as to why you think you need to do this but I have a sneaking suspicion
that if you write back with a brief description of what you are trying
to accomplish by breaking these data up we can and will happily show you
a different way that keeps your data together and will make you life
easier.
Toby Dunn
Quickly, bring me a beaker of wine, so that I may wet my mind and say
something clever.
Aristophanes
Wise people, even though all laws were abolished, would still lead the
same life.
Aristophanes
You should not decide until you have heard what both have to say.
Aristophanes
From: MikeInWV <mikeslover@GMAIL.COM>
Reply-To: MikeInWV <mikeslover@GMAIL.COM>
To: SAS-L@LISTSERV.UGA.EDU
Subject: Creating multiple datasets from one dataset based on value of a
single variable
Date: Tue, 14 Nov 2006 09:41:26 -0800
I've looked in the archives but can't seem to find a solution. If there
is one I apologize!
Here is an example of what I am looking at:
*************************************************
data all;
input client $1. val 2.;
cards;
a1
b2
c3
a4
a5
a6
a7
a8
a9
b10
b11
c12
;
run;
****************************************************
Obviously this creates a single dataset called "all" and contains 2
variables with 12 observations--for 3 different clients (A,B,C). Now,
in my case I have about 7 million observations and about 200 different
clients. I want to create 200 different datasets, each of which is
based on the value of "client". And of course I want each dataset to
equal to the value of the client. So, if I continued with the initial
dataset above I want something that gives me the equivalent of this:
data A B C;
set all;
if client='A' then output A;
else if client='B' then output B;
else if client= 'C' then output C;
run;
I DONT want to create 200 different else if statements especially since
I know that the large dataset will change over time so it needs to be
flexible. I'm sure there is a macro trick out there but I just can't
think of it.
Thanks
Mike
_________________________________________________________________
All-in-one security and maintenance for your PC. Get a free 90-day
trial!
http://clk.atdmt.com/MSN/go/msnnkwlo0050000002msn/direct/01/?href=http:/
/www.windowsonecare.com/?sc_cid=msn_hotmail
_________________________________________________________________
Add a Yahoo! contact to Windows Live Messenger for a chance to win a free
trip!
http://www.imagine-windowslive.com/minisites/yahoo/default.aspx?locale=en-us&hmtagline
|