Date: Thu, 12 May 2005 10:54:18 -0500
Reply-To: Duck-Hye Yang <dyang@CHAPINHALL.ORG>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Duck-Hye Yang <dyang@CHAPINHALL.ORG>
Subject: Re: date as a callable macro variable
Content-Type: text/plain; charset=US-ASCII
Thanks for your comments!
I am starting to see dim light at the end of long tunnel ^^ As you
pointed out, my problem needs a breakthrough, which I had no idea of.
Please see inserts.
Thanks again!
Duckhye
>>> "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM> 5/12/2005 6:22:00
AM >>>
Duck-Hye Yang wrote:
> Hello,
>
> I have a macro code (Getdates, below) for calculating distance among
> some locations.
> My problem is that I have to run this code for each date during the
> duration from 1/1/99 to 6/30/2004.
I have a strong feeling maybe not. What kind of computation or
processing
algorithm do you have to perform for each day ?
----THE DISTANCE MACRO WAS YOURS: CALCULATION OF DISTANCE BETWEEN A
PAIR OF ZIPS USING SPHERIEN DISTANCE FORMULA.
I HAVE USED IT MANY TIMES SINCE I DOWNLOADED IT.
I AM APPLYING IT TO A NEW PROBLEM: CALCULATING DISTANCE BETWEEN CRIME
SITE AND SCHOOL AND CALCULATING # INCIDENTS WITHIN 1 MILE OF SCHOOL.
%put %sysevalf ("30JUN2004"d - "01JAN1999"d);
2007
If each macro invocation creates a table, do you really want to create
2,007
tables ?
----THAT WAS THE ONLY ONE THAT I COULD THINK OF. WORSE THAN THAT, IN
FACT, I WOULD HAVE TO DO THIS 2,007 TIMES FOR EACH OF 35 SCHOOLS, WHICH
IS 35*2,007.
You can probably use arrays and/or by group processing; with maybe a
transpose or two thrown in. If you need rolling computations and have
SAS/QC
licensed, look into Proc MACONTROL of CUSUM. I don't know the
SAS/Stat
procs well, but there is likely one in that package as well for
computing
rolling metrics.
---THE FINAL DATA STRUCTURE REQUIRES TRANSPOSE: MULTIPLE RECORDS FOR A
SCHOOL WITH TOTAL # INCIDENT THAT OCCURRED ON EACH DAY WITHIN ONE MILE
OF SCHOOL. THE # OF RECORDS WOULD BE 35*2,007 WITH THREE VARIABLES,
SCHOOL, DATE, #INCIDENTS
---I AM MORE THAN WILLING TO CHECK WITH OTHER OPTIONS!!!! THANKS FOR
YOUR SUGGESTION!
> I have a sas system data (datedata, below) that contains date (in
sas
> date format).
> To make the code below working, should I convert date format to
> 01JAN1999 first?
>
> Thanks,
> Duckhye Yang
You have the appearance of onset macro-itis. Typically, one does not
quote
their macro arguments, especially if the parameter is a date value.
The
whens, hows and why nots are highly dependent on what the macro
actually
does -- which you do not show.
%getdates(findate="&date1.", out=d&date1.)
You will need to convert if you want valid OUT= values ... presuming,
OUT=
is a table name or a column name. If OUT= is neither, I would
recommend
using a parameter name other than OUT)
---- THANKS FOR YOUR ADVICE, ALTHOUGH I MAY NEED TIME TO UNDERSTAND
WHAT YOU MEANT.
AND YOU ARE RIGHT: 'OUT' WAS A TABLE NAME AS I INITIALLY PLANNED.
Richard A. DeVenezia -- Learn how to customize SAS Explorer
http://www.devenezia.com/downloads/sas/actions/