Focal Point
Compare sets of numbers

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/6571042172

February 12, 2008, 11:21 AM
Zippo
Compare sets of numbers
Hi,

I have two sets of numbers

Name Number1 Number2
John 1 5
Sam 2 5
Sally 5 7

I have another set of numbers

Dept Number1 Number2
A 2 9
B 1 5

I need a report that will count for me the number of matches between the two by Dept.

The result report would be

Dept John Sam Sally Total
A 0 1 0 1
B 2 1 1 4
Tot 2 2 1 5

Any help is greatly appreciated.

Thanks,

Zippo
February 12, 2008, 11:34 AM
Leah
Other than the numbers, do the file they are in have any key in common. Where is the data originating - probably first question.


Leah
February 12, 2008, 05:12 PM
FrankDutch
both sets of data can be written as flat files like

2 A
9 A
1 B
5 B

and

1 John
5 John
2 Sam
5 Sam
5 Sally
7 Sally

if this are the original datasets (with masters) you can join the numbers and do a count by dept and across name with totals to get the result.

But as Leah said, what are the basics....




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

February 13, 2008, 01:12 PM
Zippo
Thank you for the reply.

The files do not have any key in common. In the first file the key is NAME. In the second file the key is DEPT.

The data is in MS-Access.

I was thinking along the lines of FrankDutch and started to play with getting the data into a HOLD file that looks like this;

1 John
5 John

But didn't figure a way to do it. Tried OVER but that didn't work. I think if I know this much I am home free.

Zippo
February 13, 2008, 03:24 PM
Alan B
This may be off some help, but if you have many number columns it will get messy and McGyver could be a better choice.
-* Create sample mfds and data
FILEDEF MASTER DISK test446.mas
-RUN

-WRITE MASTER FILENAME=TEST446, SUFFIX=FIX
-WRITE MASTER SEGNAME=TEST446
-WRITE MASTER FIELDNAME=NAME, FORMAT=A06, ACTUAL=A06, $
-WRITE MASTER FIELDNAME=NUM1, FORMAT=I02, ACTUAL=A01, $
-WRITE MASTER FIELDNAME=NUM2, FORMAT=I02, ACTUAL=A01, $
-RUN
FILEDEF MASTER DISK test447.mas
-RUN

-WRITE MASTER FILENAME=TEST447, SUFFIX=FIX
-WRITE MASTER SEGNAME=TEST447
-WRITE MASTER FIELDNAME=DEPT,       FORMAT=A01, ACTUAL=A01, $
-WRITE MASTER FIELDNAME=NUM1, FORMAT=I02, ACTUAL=A01, $
-WRITE MASTER FIELDNAME=NUM2, FORMAT=I02, ACTUAL=A01, $
-RUN

FILEDEF TEST446 DISK TEST446.TXT
-RUN

-WRITE TEST446 John  15
-WRITE TEST446 Sam   25
-WRITE TEST446 Sally 57

FILEDEF TEST447 DISK TEST447.TXT
-RUN

-WRITE TEST447 A29
-WRITE TEST447 B15
-* Where code really begins This is for 2 columns of numbers, need to add more code for each extra column
SET ASNAMES=ON
TABLE FILE TEST446
PRINT COMPUTE
NUM2/I02=NUM1; AS NUM2
NUM2
BY NAME
ON TABLE HOLD
MORE
FILE TEST446
END
TABLE FILE HOLD
PRINT 
COMPUTE CNTR/I04=IF NAME NE LAST NAME THEN 1 ELSE CNTR+1; NOPRINT
COMPUTE NUMBER/I02=IF CNTR EQ 1 THEN E02 ELSE E04;
BY NAME
ON TABLE HOLD AS PERSON FORMAT FOCUS INDEX NUMBER
END
-RUN
TABLE FILE TEST447
PRINT COMPUTE
NUM2/I02=NUM1; AS NUM2
NUM2
BY DEPT
ON TABLE HOLD
MORE
FILE TEST447
END
TABLE FILE HOLD
PRINT 
COMPUTE CNTR/I04=IF DEPT NE LAST DEPT THEN 1 ELSE CNTR+1; NOPRINT
COMPUTE NUMBER/I02=IF CNTR EQ 1 THEN E02 ELSE E04;
BY DEPT
ON TABLE HOLD AS DEPT FORMAT FOCUS
END
-RUN
JOIN NUMBER IN DEPT TO ALL NUMBER IN PERSON
TABLE FILE DEPT
SUM CNT.NUMBER
ACROSS NAME ROW-TOTAL
BY DEPT COLUMN-TOTAL
END

This message has been edited. Last edited by: Alan B,


Alan.
WF 7.705/8.007
February 13, 2008, 03:26 PM
FrankDutch
Zippo

Suppose your first table is tblNames
and the master is

FILENAME=TBLNAMES, SUFFIX=FIX
SEGNAME=SEG1, SEGTYPE=S1
FIELDNAME=NAAM, ALIAS=NAAM, FORMAT=A25, $
FIELDNAME=NUMBER1, ALIAS=NUMBER1, USAGE=I5, $
FIELDNAME=NUMBER2, ALIAS=NUMBER2, FORMAT=I5, $


you can say

SET ASNAMES=ON
TABLE FILE TBLNAMES
PRINT NAAM
BY NUMBER1 AS NUMT
ON TABLE HOLD AS NAMES
MORE 
FILE TBLNAMES
PRINT NAAM
BY NUMBER2 AS NUMT
END
TABLE FILE NAMES
PRINT NAAM
BY NUMBER 
ON TABLE HOLD AS NAMES2 FORMAT FOCUS INDEX NUMT
END


Now you do the same with the department table (in the same fex)

Then you have two Focus format tables (NAMES2 and DEPT2)
They both have the field NUMT as index field.

You can join these two tables as described before.




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

February 13, 2008, 03:29 PM
FrankDutch
hi Alan.....great minds.....




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

February 13, 2008, 07:00 PM
Alan B
and fools seldom differ! Confused


Alan.
WF 7.705/8.007
February 13, 2008, 08:13 PM
Zippo
Brilliant.

This got me very far. I am having another problem now I am trying to sort out. If I need help I will start a new thread.

Thanks Again,

Zippo