Focal Point
[Resolved]Merge 2 Hold files

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

June 12, 2015, 11:18 AM
Geri
[Resolved]Merge 2 Hold files
I am sure this can be done but cannot find the solution. I have 2 hold files. One is a list of user_ids and one is a list of all calendar dates for specific month. I need to merge the 2 files into a single file for subsequent reporting. For example:

user_id
1234
5846
8412

Calendar days in text format
2014_10_01
2014_10_02
2014_10_03
2014_10_04
2014_10_05

Ultimately I need to concatenate the fields into the following:
2014_10_02_1234
2014_10_03_1234
2014_10_04_1234
2014_10_05_1234
2014_10_01_5846
2014_10_02_5846
2014_10_03_5846
2014_10_04_5846
2014_10_05_5846
2014_10_01_8412
2014_10_02_8412
2014_10_03_8412
2014_10_04_8412
2014_10_05_8412

Any ideas on how to do this? I tried match but that did not produce what I needed.

Thank you,
Geri Gellman

This message has been edited. Last edited by: Geri,




Prod: WebFOCUS 7.7.05 OS:Linux; Upgrading to: WebFOCUS 8.1.05 OS:Windows; Outputs: HTML, PDF, Excel; Adapters: SAP, MySQL, Oracle incl Report Caster
June 12, 2015, 12:44 PM
Teri Newton
You can MacGyver it.

  
SET HOLDLIST = PRINTONLY

DEFINE FILE CAR
BLANK/A1 = ' ';
END

TABLE FILE CAR
SUM
BLANK NOPRINT
BY BLANK
PRINT
CAR
BY BLANK
ON TABLE HOLD AS HOLD1 FORMAT FOCUS INDEX BLANK
END

JOIN BLANC WITH RELDATE IN MOVIES TO UNIQUE BLANK IN HOLD1 AS J1

DEFINE FILE MOVIES
BLANC/A1 = ' ';
END

TABLE FILE MOVIES
PRINT
CAR
RELDATE/YYMD
COMPUTE DATE_TXT/A9 = EDIT(RELDATE, '99_99_99_' );
COMPUTE NEWFIELD/A50 = DATE_TXT | CAR;
BY CAR
ON TABLE PCHOLD FORMAT AHTML
END




June 12, 2015, 01:24 PM
Geri
quote:
SET HOLDLIST = PRINTONLY

DEFINE FILE CAR
BLANK/A1 = ' ';
END

TABLE FILE CAR
SUM
BLANK NOPRINT
BY BLANK
PRINT
CAR
BY BLANK
ON TABLE HOLD AS HOLD1 FORMAT FOCUS INDEX BLANK
END

JOIN BLANC WITH RELDATE IN MOVIES TO UNIQUE BLANK IN HOLD1 AS J1

DEFINE FILE MOVIES
BLANC/A1 = ' ';
END

TABLE FILE MOVIES
PRINT
CAR
RELDATE/YYMD
COMPUTE DATE_TXT/A9 = EDIT(RELDATE, '99_99_99_' );
COMPUTE NEWFIELD/A50 = DATE_TXT | CAR;
BY CAR
ON TABLE PCHOLD FORMAT AHTML
END



Above is exactly what I needed! Thanks!




Prod: WebFOCUS 7.7.05 OS:Linux; Upgrading to: WebFOCUS 8.1.05 OS:Windows; Outputs: HTML, PDF, Excel; Adapters: SAP, MySQL, Oracle incl Report Caster
June 14, 2015, 06:52 PM
Waz
You could also use a condition based join.

Please see this

Just don't specify a where clause.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

June 15, 2015, 03:14 AM
Dave
...it took me some time to find a simple solution for this.

But I think I did.

SET ASNAMES = ON
TABLE FILE CAR
	BY	CAR
ON TABLE HOLD AS HLD_CAR
END

TABLE FILE CAR
	BY	COUNTRY
ON TABLE HOLD AS HLD_COUNTRY
END

-* SQL join
SQL
SELECT
	HLD_CAR.CAR, HLD_COUNTRY.COUNTRY
FROM HLD_CAR
INNER JOIN HLD_COUNTRY;
TABLE HOLD AS HLD_CARTESIAN
END
-RUN

TABLE FILE HLD_CARTESIAN
	PRINT *
END


Yes, this works.
You can even add join-conditions ( in sql ).
Or even some other SQL stuff.


SQL
insert into HLD_CARTESIAN ( CAR , COUNTRY ) VALUES ( 'DODGE' , 'USA' );
END


tags for future reference:
cartesian
cartesian product
sql join
conditional join
sql insert

[ should we start using #hashtags?? ]


_____________________
WF: 8.0.0.9 > going 8.2.0.5