Focal Point Banner


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.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Random Sample

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED] Random Sample
 Login/Join
 
Gold member
posted
Is there a way to only return a true random sample of data queried via WebFocus.

This message has been edited. Last edited by: <Kathryn Henning>,


WebFOCUS 7.7 and WebFOCUS 8
Windows, All Outputs
 
Posts: 36 | Registered: August 17, 2010Report This Post
Platinum Member
posted Hide Post
You can do that using RECORDLIMIT OR READLIMIT...

thanks
Sashanka


WF 7.7.03/Windows/HTML,PDF,EXL
POC/local Dev Studio 7.7.03 & 7.6.11
 
Posts: 103 | Registered: June 12, 2009Report This Post
Expert
posted Hide Post
But it isn't a true random sample.

I believe that in computing in general a true random sample is impossible.


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!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Virtuoso
posted Hide Post
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, 2007Report This Post
Platinum Member
posted Hide Post
Assuming RDUNIF is sufficiently random for your purposes, would this do the trick?

-SET &SAMPLE_PERCENT = .10 ;
TABLE FILE GGSALES
PRINT
COMPUTE RAND/D9.8=RDUNIF(RAND);
SEQ_NO DOLLARS/D8M
WHERE TOTAL RAND LE &SAMPLE_PERCENT
END


WebFOCUS 8.2.06
 
Posts: 210 | Location: Sterling Heights, Michigan | Registered: October 19, 2010Report This Post
Expert
posted Hide Post
sweet




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
Virtuoso
posted Hide Post
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, 2006Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Random Sample

Copyright © 1996-2020 Information Builders