03-21-2013 09:07 AM
I have a custom task for Calculate Running Totals. You can download it at:
See the Chapter 11 example. You can download the Binaries and install the task per the instructions in the free chapter of my book.
Alternatively, you can achieve this fairly easily with DATA step. See this SAS Note for an example.
03-21-2013 09:27 AM
I need a running count not total. In another tool, I use running-count(zipcode for Group number). I call the calculated column runningctzip. It counts the number of zipcodes for a group number - 1,2 etc. Then I say runningctzip = 1 because I only want the first one. Anything like that in SAS?
03-21-2013 09:52 AM
Group Number Zip Calculated column - runningct(zip for Group Number) called ZipCnt
01 15108 1
01 15233 2
02 12222 1
03 13333 1
03 12344 2
03 13456 3
Since I only want the first Zip, I would say ZipCnt =1
03-21-2013 11:27 AM
This loop might get you close.
by Group_Number ZIP_Code;
by Group_Number ZIP_Code;
if first.Group_Number and first.ZIP_Code then sub_total =0;
03-21-2013 12:01 PM
I just thought there was some simple way to do this in Enterprise Guide. Would I have to open a program to run this? I don't understand the logic. I am very new to SAS. I just want a calculated column that counts the zip codes for Group Number.
03-21-2013 12:23 PM
Add your data to your project.
Go to Tasks>Describe.
Try a few of the procedures to see what they give you. You're probably looking for a table analysis or a one way freq.
If you really only want the first record of a data set then look at TASKS>DATA>SORT. Under the options for the Sort procedure you can keep just the first of each sorted field.
03-25-2013 11:08 AM
there is a function called monotonic() that might help you.
If you right click on your data and choose query builder in EG then do the following,
add the GroupNumber and Zip columns to the select data tab
add a computed column as an advanced expression and type monotonic() as the expression.
call the column 'rank' or something clear for you.
back in the main window add your 'rank' column a second time and choose MIN from the Summary drop down.
make sure that the summary groups are only on Group number (this is important)
(see attached screenshot)
when you run the task your output data should have a rank and a min_of_rank column.
if you filter this data for where the two columns are equal that should give you what you want.
you will probably need to do it as two steps since it seemd to complain when i tried to put the filter in in the same query.
Hope this helps.