July 25, 2005, 09:29 PM
Paul C.Use of Hold File results in a compute field
I have a hold file that contains a count (one row, one column). I would like to use that count in a compute field. How can I do something like this?
COMPUTE NEWVALUE/D12.2 = MYCOLUMN/HOLDCOUNT
The hold file value will be applied to each row returned in MYCOLUMN from the join.
July 25, 2005, 10:16 PM
N.SelphYou want to do a -READ on your hold file, and read the value into an &variable. Then you can use the &variable in your compute.
-READ holdfile &VARNAME.I6.
(or however long your count value is.)
July 26, 2005, 04:09 AM
Paul C.That still prompts me to fill in a variable. Here is the code, I'm hitting a Date table that will give me a list of dates and information about those dates.
-SET &STARTDATE='6/1/2005';
-SET &ENDDATE='6/7/2005';
TABLE FILE DATE
COUNT DATE.DATEKEY
WHERE DATE.FULLDATE FROM '&STARTDATE' TO '&ENDDATE'
AND
DATE.WEEKDAYINDICATOR EQ 'YES'
AND
DATE.HOLIDAYINDICATOR EQ 'NO'
ON TABLE HOLD AS CALENDAR
END
-*? HOLD CALENDAR
-RUN
-READ CALENDAR &DAYCOUNT.I5.
-? &DAYCOUNT
END
The value entered on the prompt shows in the resultant output. Not the value from the hold file. There is one record in the table with a value of 5 which is the number of business days between the dates and not a holiday. The value returned on the @variable is 2 which is what was entered at the parameter prompt.
0 NUMBER OF RECORDS IN TABLE= 1 LINES= 1
CURRENTLY DEFINED & VARIABLES STARTING WITH 'DAYCOUNT':
&DAYCOUNT = 2
July 26, 2005, 08:50 AM
Tony APaul,
Try putting a comma after the holdfile name in the READ and forget about the format.
Also force the output format in ALPHA so that you can read the variable and not have a byte value -
TABLE FILE DATE
COUNT DATE.DATEKEY
WHERE DATE.FULLDATE FROM '&STARTDATE' TO '&ENDDATE'
AND
DATE.WEEKDAYINDICATOR EQ 'YES'
AND
DATE.HOLIDAYINDICATOR EQ 'NO'
ON TABLE HOLD AS CALENDAR FORMAT ALPHA
END
-*? HOLD CALENDAR
-RUN
-READ CALENDAR, &DAYCOUNT
-? &DAYCOUNT
END