Date: Thu, 23 Sep 2004 08:32:17 -0400
Reply-To: Peter Crawford <peter.crawford@BLUEYONDER.CO.UK>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Peter Crawford <peter.crawford@BLUEYONDER.CO.UK>
Subject: Re: Summing lines of a SAS dataset??
Hi Howard
Of course you are correct on all points:-
non-uniqueness and misspellings may well be issues
I'm not going to give more than hints to a solution, when
the business requirement remains ill-defined at that level.
However, the table citystate will allow the original poster
to explore these issues with a substantial resource - at no
extra cost to them.
Kind Regards
Peter
On Thu, 23 Sep 2004 04:05:32 -0700, W Dennis Diskin <diskin@ALUM.RPI.EDU>
wrote:
>Isn't Albany in Georgia? Oh wait, it might be California, Oregon,
>Indiana, Illinois, Kentucky, Louisianna, Minnesota or Missouri. Or was
>it a country?
>
>
><-----Original Message----->
>
> From: Howard Schreier
>Sent: 9/22/2004 11:13:55 PM
>To: SAS-L@LISTSERV.UGA.EDU
>Subject: Re: Summing lines of a SAS dataset??
>
>Clever advice (as usual) from Peter, but a little attention to detail is
>still needed. Does the SAS map dataset have all of the cities referenced
>in
>Julie's data? Are there perhaps spelling differences (Pittsburg vs.
>Pittsburgh) which will foul up the lookup?
>
>On Wed, 22 Sep 2004 18:04:23 -0400, Peter Crawford
>wrote:
>
>>some of these ideas are OK some good, but all seem to miss the
>>trick
>>
>>among the maps data library I have table citystate(came with SAS)
>>providing both ...... just what you need!
>>
>>The other, associated, idea is the cntlin= dataset option for proc
>format
>>
>>Put them together to simplify and solve......
>>along with the idea that proc summary provides by default(iirc)
>>totals by formatted value of class vars
>>
>>Good Luck
>>Peter Crawford
>>
>>On Wed, 22 Sep 2004 14:42:06 -0700, Pardee, Roy wrote:
>>
>>>And to get you started on that format, try this:
>>>
>>>Proc sql ;
>>> select disinct "'" || trim(city_state) || "' = ''"
>>> from my_table ;
>>>Quit ;
>>>
>>>That should spit out text like so in your .lst file:
>>>
>>> 'Maryland' = ''
>>> 'Virginia' = ''
>>> 'New York' = ''
>>> <>
>>>
>>>Which you can then copy/paste into your program, after adding the call
>>>to PROC FORMAT etc., and fill in w/the proper values.
>>>
>>>HTH,
>>>
>>>-Roy
>>>
>>>-----Original Message-----
>>>From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
>>>Fehd, Ronald J.
>>>Sent: Wednesday, September 22, 2004 1:50 PM
>>>To: SAS-L@LISTSERV.UGA.EDU
>>>Subject: Re: Summing lines of a SAS dataset??
>>>
>>>
>>>> From: Julie
>>>> suppose I have a SAS dataset for a bunch of states and states, such
>>>> as...
>>>>
>>>> A B C
>>>> Maryland 33 50 54
>>>> Virginia 35 64 79
>>>> New York 65 74 33
>>>> Ohio 31 82 29
>>>> Baltimore 22 13 34
>>>> Albany 11 20 22
>>>> Cleveland 22 21 34
>>>> Arlington 60 40 72
>>>>
>>>> Is there a simple code you can write to ask the SAS program to add
>>>> all Albany numerical data (in each column) to New York's data (i.e.
>so
>>>
>>>> the final data set would read New York 76 94 67 on one line)
>>>> Cleveland's numerical data to Ohio's numerical data (i.e. so the
>final
>>>
>>>> data set would read Ohio 53 103 63 on one line) and so on and have
>>>> these summed up numbers by state in one final dataset?? I hope
>someone
>>>> understands what I'm trying to do... thanks!!!
>>>
>>>as Toby said, with some hefty coding
>>>
>>>you'll need to add State
>>>then you can sum by state
>>>with proc Means, etc.
>>>
>>>I would suggest a format:
>>>PROC Format $City2State
>>>'Baltimore' = 'MD'
>>>'Cleveland' = 'OH'
>>>...;
>>>Data City2State;
>>>attrib State length = $ 2;
>>>set Miscellaneous;
>>>State = put(CityOrState,$City2State.);
>>>
>>>PROC Means/Summary;
>>> etc.
>>>
>>>Ron Fehd the macro maven CDC Atl GA USA
>.
|