As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.
Join the TIBCO Community TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.
From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
Request access to the private WebFOCUS User Group (login required) to network with fellow members.
Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.
Here's an idea for generating a random sample from a set of records, using the RDUNIF random number function:
SET HOLDLIST = PRINTONLY
SET ASNAMES = ON
-*
-* Set the desired sample size percent.
-SET &SAMPLE_PERCENT = .10 ;
-*
-* Determine the total population size (DENOMINATOR) and related sample size.
TABLE FILE GGSALES
SUM
CNT.SEQ_NO/I10 AS 'DENOMINATOR'
COMPUTE SAMPLE_SIZE/P10 = CNT.SEQ_NO * &SAMPLE_PERCENT ;
ON TABLE HOLD AS STATS
END
-*
-RUN
-* Read the DENOMINATOR and SAMPLE_SIZE values into variables.
-READFILE STATS
-* Determine the number of digits needed to extract an appropriate sample size.
-SET &TRIM_DENOM = TRIM('B',&DENOMINATOR,&DENOMINATOR.LENGTH,' ',1,'A&DENOMINATOR.LENGTH');
-SET &DIGITS = ARGLEN(&TRIM_DENOM.LENGTH,&TRIM_DENOM,'I3');
-SET &SIGNIFICANT = &DIGITS + 1 ;
-SET &MULTIPLIER = 1 ;
-*
-* Because function RDUNIF creates random numbers between 0 and 1, generate a MULTIPLIER
-* to force the decimal numbers into an appropriate sample size range. The multiplier
-* is based on the number of digits in the denominator.
-REPEAT :ENDREPEAT1 &DIGITS TIMES
-SET &MULTIPLIER = &MULTIPLIER || '0';
-:ENDREPEAT1
-*
-* Use function RDUNIF to generate a random number for each record.
-* The number of digits and appropriate multiplier are applied.
DEFINE FILE GGSALES
RANDOM/P&DIGITS WITH SEQ_NO = RDUNIF('D&SIGNIFICANT...&DIGITS') * &MULTIPLIER ;
END
-*
-* Use the sample size calculated above to extract a random set of records from the population.
TABLE FILE GGSALES
PRINT SEQ_NO DOLLARS/D8M
BY LOWEST &SAMPLE_SIZE RANDOM AS 'Random#'
END
WebFOCUS 7.7.05
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007
If you have a real big number of records and you want a random selection of let's say 100 records this wont be easy. Unless you know exactly what the key fields are. Suppose the key field is a sequential number from 1 till X and you know the highest number then you can have webfocus generate a list of 100 random numbers based on the number X. Then send the request to the database with exactly the numbers you want to get back. But if the sequence is not contiguous this will result in missing records. If you would follow Dan's solution you need to download all the data first to webfocus.
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
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006