September 04, 2007, 05:29 PM
gregson06Numbered listing
Here's my scenario. I would like to do something like a list with groups, except that I don't want the numbers to restart after each group.
So it should look like this:
Group A
1 car
2 truck
3 van
Group B
4 motorcycle
5 moped
6 scooter
Is there a way to do this with LIST, or must I use a DEFINED field for this?
Thanks!
September 04, 2007, 05:48 PM
LeahFar as I know list numbers based on a by field. I'd use a compute to get your 'list' as the first field in the list.
compute countlist/i5 = if countlist eq 0 then 1 else countlist + 1; as 'LIST'
Of course many ways to skin a cat. Define won't work unless the file is in the order you want to 'list it'.
September 04, 2007, 06:01 PM
gregson06Thanks Leah,
It worked the following way (similar to what you mentioned):
TABLE FILE DATA
PRINT
CAR
YEAR
BY CAR
BY YEAR
ON TABLE HOLD AS DATA1
END
DEFINE FILE DATA1
CNTR/I6 = IF CNTR EQ 0 THEN 1 ELSE CNTR+1;
END
TABLE FILE DATA1
PRINT
CNTR
CAR
YEAR
ON TABLE HOLD AS DATA2
END
TABLE FILE DATA2
PRINT
CNTR
CAR
BY CAR
BY YEAR
END
This basically gets the data that I need sorted on the first pass, then adds the counter on the second pass, then displays the counter in the groups I need them in on the last pass.
Thanks a bunch!
September 05, 2007, 02:43 AM
Tony AYou should be able to do it in a single pass - depending upon the number of fields you have in the output and their layout etc.
TABLE FILE GGSALES
SUM COMPUTE LIST/I9 = LAST LIST + 1;
ST
DOLLARS
-* This is your group field
BY REGION NOPRINT
-* This is the field that you want ranked within your report
BY ST NOPRINT
ON REGION SUBHEAD
"Region <REGION"
END
T
September 05, 2007, 03:26 AM
PiipsterI might stay away from LIST as a fieldname. It was a valid verb in the past and as such would be a reserved word. I don't know if it works now though and I've just shut down my vmware image. I'll test it out tomorrow if I get a chance.
September 05, 2007, 03:37 AM
Tony AVery true Karen, forgot about that! (early morning etc.
) However, it worked on 7.6.2 on Windows this am.
T
September 05, 2007, 05:27 AM
Danny-SRLThis could help:
DEFINE FILE CAR
DUM/A1=' ';
END
TABLE FILE CAR
LIST CAR
BY DUM NOPRINT
BY COUNTRY NOPRINT SUBHEAD
"Group: <COUNTRY "
END
September 05, 2007, 01:11 PM
ETThis also works.
TABLE FILE CAR
PRINT COMPUTE CNTR/I9=CNTR + 1; AS LIST CAR
BY COUNTRY
END
COUNTRY LIST CAR
------- ---- ---
ENGLAND 1 JAGUAR
2 JENSEN
3 TRIUMPH
FRANCE 4 PEUGEOT
ITALY 5 ALFA ROMEO
6 MASERATI
JAPAN 7 DATSUN
8 TOYOTA
W GERMANY 9 AUDI
10 BMW