[SOLVED] Convert alpha date in mainframe FOCUS to date format
I have a datafile that contians dates in alphaformat, ,arranged as so: 20082 (Contains only the current year and a number representing a particular quarter of the year). How might I convert that date to a numeric calendar format?
I'm running mainframe FOCUS Release 7.1, which is awfully arcaic, but I work for an educational organization and can only work with what tools I am given.
Thanks in advance!This message has been edited. Last edited by: Kerry,
Mainframe FOCUS 7.0 VM/CMS and MVS/TSO
December 17, 2008, 10:28 AM
Maintain Wizard
This is a very easy task for Maintain. Your code could look like this:
MAINTAIN COMPUTE X/A10 = '20082'; COMPUTE Y/A4 = SUBSTR(X, 1, 4); COMPUTE Z/A1 = SUBSTR(X, 5, 1); COMPUTE Z1/A4; IF Z = 1 THEN COMPUTE Z1 = '0101'; IF Z = 2 THEN COMPUTE Z1 = '0401'; IF Z = 3 THEN COMPUTE Z1 = '0701'; IF Z = 4 THEN COMPUTE Z1 = '1001'; COMPUTE X2/MDYY= Z1 || Y; TYPE "X2 = <END
Here I am just computing X to a value, but you could load the data into a stack and do a loop. I get the year and the quarter, and just compute them to a standard MDYY assuming standard starting dates of quarters.
If you need help loading the data or creating the loop, post the Master. Of course, the format of X2 can be an alpha or any other date format.
Mark
December 17, 2008, 10:28 AM
Francis Mariani
DEFINE FILE CAR
DT_YQ/A5 WITH COUNTRY =
IF COUNTRY EQ 'ENGLAND' THEN '20091' ELSE
IF COUNTRY EQ 'FRANCE' THEN '20042' ELSE
IF COUNTRY EQ 'ITALY' THEN '20083' ELSE '20044';
DATE1/A8 =
IF EDIT(DT_YQ,'$$$$9') EQ '1' THEN EDIT(DT_YQ,'9999$') || '0101' ELSE
IF EDIT(DT_YQ,'$$$$9') EQ '2' THEN EDIT(DT_YQ,'9999$') || '0401' ELSE
IF EDIT(DT_YQ,'$$$$9') EQ '3' THEN EDIT(DT_YQ,'9999$') || '0701' ELSE
IF EDIT(DT_YQ,'$$$$9') EQ '4' THEN EDIT(DT_YQ,'9999$') || '1001' ELSE '0';
DATE2/I8 = EDIT(DATE1);
END
TABLE FILE CAR
PRINT DATE2
END
You can further convert DATE2 to a Date format or a Date-Time format field.
(
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
December 17, 2008, 10:50 AM
webmeister
Maintain and Francis,
Thank you for your fast replies! I think I suffered from brain loss earlier, and I appreciate your helping out. I'm incorporating your suggestions and think I will get this fixed very soon.
where MYAINPUT is your A5 input and MYD is a normal FOCUS newdate, which can be directly converted into any olddate format (e.g. A8YYMD etc.)
IBI Development
December 17, 2008, 11:29 AM
j.gross
If you could define the incoming string as a legacy date field with YY and Q components, you could transform the legacy date to a 'smart' date by direct assignment. But the Q option was never incorporated in the legacy formats, so you have to make do with year+month formats.
Isolate the year and quarter, compute a month in the quarter, construct a legacy year+month date, and assign that to a year+quarter date: EX -LINES 5 EDAPUT MASTER,DATES,CV,FILE FILENAME=DATES, SUFFIX=FIX,$ SEGNAME=DATES, $ FIELD=DATE1 ,ALIAS=,A5 ,A5 ,$ FIELD=IGNORE ,ALIAS=,A75 ,A75 ,$
EX -LINES 5 EDAPUT FOCTEMP,DATES,CV,FILE 20001 20012 20023 20034
FILEDEF DATES DISK DATES.FTM DEFINE FILE DATES
AQ /A1=EDIT(DATE1,'$$$$9');
AM /A2=DECODE AQ( 1 '03', 2 '06', 3 '09', ELSE '12');
AYYM /A6YYM=EDIT(DATE1,'9999') | AM;
YYQ /YY-Q=AYYM;
END TABLEF FILE DATES LIST DATE1 AQ AM AYYM YYQ END
- Jack Gross WF through 8.1.05
December 18, 2008, 03:34 PM
Waz
Can you just change the Usage of the master ?
EX -LINES 5 EDAPUT MASTER,DATES,CV,FILE
FILENAME=DATES, SUFFIX=FIX,$
SEGNAME=DATES, $
FIELD=DATE1 ,ALIAS=,YYQ ,A5 ,$
FIELD=IGNORE ,ALIAS=,A75 ,A75 ,$
EX -LINES 5 EDAPUT FOCTEMP,DATES,CV,FILE
20001
20012
20023
20034
FILEDEF DATES DISK dates.ftm
TABLE FILE DATES
PRINT DATE1
END