Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Generate the test Data following some quota conditions

Hello,
 
I wanted to Generate some test data using the data Generator, and have to following some quota conditions.
 
e.g. I want to Generate 100 cases data that has :
70 males/ 30 females,
and 30 from city1/ 40 from city2 /30 from city3
……and so on.
 
For this purpose, How can I set?
asked May 6 by ben

1 Answer

0 votes
The Defined Values tab of the Data Generator can be used to force robotic respondents to answer questions in specific ways.  The code to do this can vary depending on how you want the respondents to behave exactly, but here's a simple example.  The first seventy respondents will respond with option 1 (male), while the remaining thirty will respond with option 2 (female):

Begin Unverified Perl
if (RESPNUM() <= 70) {
    return 1;
}
else {
    return 2;
}
End Unverified
answered May 6 by Zachary Platinum Sawtooth Software, Inc. (120,900 points)
hi Zachary, many thanks.

I change the code following your example.  but it did not work. can you help to fix it? here is the code i wrote.

Begin Unverified Perl
if (RANDNUM(1) <= 0.7) {
    return 1;
}
else {
    return 2;
}
End Unverified
If you want respondents to be randomly put into one group or the other, you probably want to use SysRand instead of RandNum.  The response on this post explains the difference between these two functions:

https://sawtoothsoftware.com/forum/21422
I know both,  but my problem is "The Logic failed to evaluate. Undefined subroutine &SSI::SSIWeb::Perltools::SYSRAND called at (eval 10) line 3. " when I use RANDNUM or SysRand .
BTW, I use rand(10) instead of RandNum or SYSrand.
The syntax works.
What's the difference between the rand(), Randmun(), and SYSrand()?
rand is the random number generator built into Perl.  It's random distribution ought to be similar to SysRand, but I haven't ran the statistical analysis there.  Mostly SysRand just makes it easier to set a minimum and maximum, but that can be done with regular Perl without too much difficulty.

Using RandNum involves a special seed parameter that makes it behave differently than rand and SysRand.  The link I posted above goes into detail about how seeds work.
...