/*This example generates a data set with one variable and a number of records that is previously specified by the user. To do this, an input panel is opened before the execution. START ADaMSoft, copy the script in the command editor window and press F8*/ scl; String str = JOptionPane.showInputDialog(null, "Enter the number of records to generate: ", "Test for an input box", 1); double nrecords=NAN; if (str!=null) { nrecords=TEXT2NUM(str); if (!ISMISSING(nrecords)) ADDDEFINE("number", str); } if (ISMISSING(nrecords)) ADDDEFINE("number", "100"); run; dataset out=test; newvar random_value=num; for (int i=0; i<&number; i++) { random_value=RNDUNIFORM(); output; }; run; /*HOW IT WORKS: *** It is called the SCL step (a special step in which are executed some statements without creating a new data set scl; *** In the String "str" it is copied the value inserted by the user in a panel String str = JOptionPane.showInputDialog(null, "Enter the number of records to generate: ", "Test for an input box", 1); *** the "nrecords" is defined as a number and it is initialized to missing double nrecords=NAN; *** if the value of "str" is different to null if (str!=null) { *** the nrecords is obtained by transforming the "str" in a number nrecords=TEXT2NUM(str); *** if the transformation went ok (the result is a number)... the it is added a new DEFINE, named "number", with the value *** given by "str" if (!ISMISSING(nrecords)) ADDDEFINE("number", str); } *** if "nrecords" is still missing, the DEFINE named "number" is automatically initialized to 100 if (ISMISSING(nrecords)) ADDDEFINE("number", "100"); run; *** here it is executed the code that generates a number of records given by the value of the DEFINE named "number dataset out=test; newvar random_value=num; *** When ADaMSoft finds a "&" before a variable, it looks in the DEFINEs in order to verify if exists one with the *** given name. In that case the value of the define is substituted for (int i=0; i<&number; i++) { random_value=RNDUNIFORM(); output; }; run; */