Date: Fri, 5 Sep 2008 12:28:59 -0400
Reply-To: Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Subject: Re: Advanced Macro Class
I think that it's not a important criteria that something can be done in
another way. It is important for me, that a example is simple, to
demonstrate the macro technique and not deviate from that by a
sophisticated SAS problem where there is no other simple solution as
programming it like it is. 90% of all solutions are not the only ones,
especially in SAS there are nearly always others, sometimes much more
elegant. That is my experience with making proposals here in the list: 2
minutes later there are some others, sometimes much more elegant,
something what I like very much here by the way.
If I had to develop a course, I'd choos NO complicated problems to show
how they can be solved and I'd never say, that mine is the best solution!
I'd choose a thing which is simple enough that nobody has a problem to
understand it and show a technique which is kind of universal and for sure
also usable for more complex problems.
Eg. if one would show, how hash objects could be used, why not taking
SASHELP.CLASS and find the age or sex by name? Very silly to use a hash-
object for that. Use FSVIEW or the SAS viewer and have a look on it. Much
faster. Or use a WHERE clause, not only faster, but better, because there
are no problems with duplicate names! But I think that is a good thing to
show a principle, also to show the limits (what about duplicate names?)
and avoid too much problems which have nothing to do with that, what you
want to show. So my idea would be, to keep it all as simple as possible.
If you increase the complexity to show how "important" your technique is,
you produce too much overhead. The attendees of a class should not have
only learned that the technique is important, maybe it is more interessant
for them to have the skill to operate with it, not to tell the world, that
there is a "very important technique to solve that problem, but it's to
complicated for me...". It is not! All computer languages are simple!
That's the goal to show, not how complex it is!
Why is it so bad, that a technique is shown with the help of a
simple "problem"?
Ok, with a real problem, where the "best", or at least a good solution is
wanted, it might be no good idea to say, "I was on a macro course last
week and I start to make it all with macros now". Would be good to know
about some other possible solutions also. So it might be a good idea to
post a question here, where many people with good knowledge and sometimes
very long experience can tell about their ideas. That's always better than
hours of lonesome "brainstorming", sometimes simply because you know about
the way, you "usually choose". There might be some better ways, or simply
some others, which are worth to think (or/and talk) about.
And again: that has nothing to do with SAS-classes! I always hated that
people there, who always come up with there "100 other ways to do it..."!
Have a nice weekend!
Gerhard
On Fri, 5 Sep 2008 10:28:16 -0500, ./ ADD NAME=Data _null_,
<iebupdte@GMAIL.COM> wrote:
>You have been complaining about this class even before you took it.
>Lets work on these awful examples, so the "Ivory Billed Woodpeckers"
>can see them and improve this course.
>
>We can start with the example you refer to. What macro technique was
>being demonstrated? What would be a better example?
>
>When we beat this one to death we can move on to other irritating
examples.
>
>On 9/5/08, Toby Dunn <tobydunn@hotmail.com> wrote:
>> Cherish,
>>
>> This is one of those examples I saw and hated in the Advanced Macro
class
>> I attend last week. No macro is needed at all. Ideally you want your
>> data stored together in one data set, this allows for more efficient
>> storage and utilization of the data. With that in mind look up the
>> FileVar option on the Infile Statement. Or search the SAS-L archives as
>> there are plenty of exmaples their.
>>
>> Toby Dunn
>>
>> On Fri, 5 Sep 2008 09:29:36 +0100, cherish k <hawks_cherish@YAHOO.CO.IN>
>> wrote:
>>
>> >Hi All,
>> >
>> >I have approximately 1000 files in txt format separated by comma. I
need
>> to convert them in SAS datasets with a single conversion code. File
>> formats are same for all the files.
>> >
>> >Only problem being that the file names are in this format: file_000001
>> >
>> >so if the file number is 95 then the file name is: file_000095
>> >
>> >I used the following code
>> >
>> >%macro conv(j,k);
>> >
>> >data File_&k.;
>> >infile "C:\Documents and Settings\cherish\My
>> Documents\Cherish\file_&j..txt" delimiter = ',' MISSOVER DSD lrecl=32767
>> firstobs=2 ;
>> >informat VAR1 best32. ;
>> >format VAR1 best12. ;
>> >input
>> > VAR1
>> >;
>> >FILE_NO = &k;
>> >run;
>> >
>> >
>> >%mend conv;
>> >
>> >
>> >
>> >%macro conv_call;
>> >
>> >%do i = 1 %to 1000;
>> >
>> > %if %eval(&i) < 10 %then %conv(00000&i.,&i.);%else %if %eval(&i) <
>> 100 %then %conv(0000&i.,&i.);%else %if %eval(&i) < 1000 %then %conv
>> (000&i.,&i.);
>> >
>> >
>> >%end;
>> >
>> >%mend conv_call;
>> >
>> >%conv_call;
>> >
>> >Is there a better way of doing this? i.e. instead of writing so many %
if %
>> else statements?
>> >
>> >Cherish
>> >
>> >
>> >---------------------------------
>> > Unlimited freedom, unlimited storage. Get it now
>>
|