Hi, here is the source Year ID 1994 10 1994 12 1994 13 1995 11 1996 10 1996 13 1997 10 1997 14 1998 15 1998 16
The output I need is a count of IDs by year only one one condition that the ID's do not occur in the previous years..
year counts 1994 3 1995 1 1996 0 1997 1 1998 2
In other words for the year 1994 we account all IDs since thats the first year and 1995 we only count the ones that are newly added for that year and dont include any from the past and so on and so forth...
I tried to create a flag but not sure how to raise it using LAST command for my situation..
TABLE FILE MYFILE
PRINT ID COMPUTE CNTR/I5=IF ID NE LAST ID THEN 1 ELSE 0;
BY YR
END
Hope thismakes sense..pls let me knowThis message has been edited. Last edited by: Kerry,
June 07, 2011, 04:10 PM
RSquared
Try this.
TABLE FILE MYFILE SUM CNT.ID BY YR END
WF 7.6.11 Oracle WebSphere Windows NT-5.2 x86 32bit
June 07, 2011, 04:14 PM
vaayu
Sorry if it seemed so simple...maybe I wasnt clear in explaining the problem...I need to count the IDs for each year making sure they are not accounted in the previous years already...please see my input/output...
Thanks for looking into this...
June 07, 2011, 04:55 PM
vaayu
Francis or Susanah
Please help!
June 07, 2011, 04:56 PM
Mighty Max
Does this give you what you need?
-* File prc_year_id.fex
FILEDEF YEAR_ID DISK year_id.txt
-RUN
-WRITE YEAR_ID 199410
-WRITE YEAR_ID 199412
-WRITE YEAR_ID 199413
-WRITE YEAR_ID 199511
-WRITE YEAR_ID 199610
-WRITE YEAR_ID 199613
-WRITE YEAR_ID 199710
-WRITE YEAR_ID 199714
-WRITE YEAR_ID 199815
-WRITE YEAR_ID 199816
FILEDEF MASTER DISK year_id.mas
-RUN
-WRITE MASTER FILENAME=YEAR_ID, SUFFIX=FIX
-WRITE MASTER DATASET=year_id.txt, $
-WRITE MASTER SEGNAME=YEAR_ID, SEGTYPE=S0, $
-WRITE MASTER FIELDNAME=YEAR, FORMAT=A4, ACTUAL=A4, $
-WRITE MASTER FIELDNAME=ID, FORMAT=A2, ACTUAL=A2, $
-RUN
TABLE FILE YEAR_ID
SUM
YEAR
ID
COMPUTE CNTR/I8 =IF ID NE LAST ID THEN 1 ELSE 0;
BY ID NOPRINT
BY YEAR NOPRINT
ON TABLE HOLD AS H1
END
TABLE FILE H1
SUM
YEAR AS 'Year'
CNTR AS 'Counts'
BY YEAR NOPRINT
END
-EXIT
In that case try sorting the data by ID by YR. TABLE FILE MYFILE PRINT YR BY ID ON TABLE HOLD AS HOLDFILE END DEFINE FILE HOLDFILE COUNTIT/I4=IF ID EQ LAST ID THEN 0 ELSE 1; END TABLE FILE HOLDFILE SUM COUNTIT BY YR END
WF 7.6.11 Oracle WebSphere Windows NT-5.2 x86 32bit
June 07, 2011, 05:00 PM
Francis Mariani
Might Max's solution seems to work...
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
June 07, 2011, 05:39 PM
vaayu
Thank you all...Let me work with it and see...
June 07, 2011, 06:03 PM
vaayu
COUNTIT/I4=IF ID EQ LAST ID THEN 0 ELSE 1; did the trick..although I tried it but did not check the results properly since there are few hundreds and only few get a flag..
Thanks again, Appreciate the help from all the FOCUSers