|
|
How to generate non-repeated random integers
Dear all,
My problem is like this.
I want to simulate artificial data ranking 15 criteria (C1, .... ,
C15).
So, each observation should have any rank value between 1 and 15 to
each variable (criterion).
To do so, I have to assign an integer number between 1 and 15 to each
criterion without repetition of them.
After repeating this process, I wish to have 100 observations.
Your help will be appreciated.
Best regards,
Kilkon
|
|
0
|
|
|
|
Reply
|
Netguy
|
7/6/2010 3:25:25 PM |
|
Hi Kilkon
Hope the code below does what you're after:
data _null_;
length ValList $ 30;
ValList=put(1,z2.);
do i=2 to 15;
ValList=cats(ValList,put(i,z2.));
end;
call symput('ValList',cats(ValList));
run;
%put ValList=&ValList;
data want(keep=ID C1-C15);
array c {15} 8.;
do ID=1 to 100;
ValList="&ValList";
do i=1 to 15;
RemainingElements=length(ValList)/2;
PickElement=ceil(ranuni(0)*RemainingElements);
c{i}=substr(ValList,(2*PickElement -1),2);
substr(ValList,(2*PickElement -1),2)='';
ValList=compress(ValList);
end;
output;
end;
run;
proc print data=want;
var ID C1-C15;
run;
HTH
Patrick
|
|
0
|
|
|
|
Reply
|
Patrick
|
7/7/2010 1:34:12 AM
|
|
|
1 Replies
855 Views
(page loaded in 0.055 seconds)
Similiar Articles: How to generate non-repeating random integers - comp.soft-sys ...Hi all, Does anybody know how to generate a series of say 450 non-repeating random integers between 0 and 2000? Thanks ... How to generate non-repeated random integers - comp.soft-sys.sas ...Dear all, My problem is like this. I want to simulate artificial data ranking 15 criteria (C1, .... , C15). So, each observation should have any r... How to generate proper seeds for the rand function in Monte Carlo ...How to generate non-repeating random integers - comp.soft-sys ... How to generate proper seeds for the rand function in Monte Carlo ..... all, I'm trying to evaluate ... non-repeating, random, textures ... - comp.graphics.api.opengl ...How to generate non-repeated random integers - comp.soft-sys.sas ... generating a coloured noise - comp.soft-sys.matlab non-repeating, random, textures ... - comp.graphics ... Help Non Integer sampling rate conversion c code - comp ...How to generate non-repeated random integers - comp.soft-sys.sas ... Creating random decimal numbers in C - comp.soft-sys.matlab ... Help Non Integer sampling rate ... How to generate random number without replacement? - comp.lang ...How to generate non-repeated random integers - comp.soft-sys.sas ... Non-Repeating Random Integers I trying to make a list of 100 random numbers between 1 and 100 without ... how to generate id - comp.soft-sys.matlabHow to generate non-repeated random integers - comp.soft-sys.sas ..... ValList',cats(ValList)); run; %put ValList=&ValList; data want(keep=ID C1-C15 ... to tell me if it ... Randomly permute a given set of numbers - comp.soft-sys.matlab ...How to generate non-repeated random integers - comp.soft-sys.sas ... How to generate random number given density function ... and/or one whose colour components vary ... How do I determine whether a text string is a number/whole/integer ...How to generate non-repeating random integers - comp.soft-sys ... How do I determine whether a text string is a number/whole/integer ... How to generate non-repeating ... Creating random decimal numbers in C - comp.soft-sys.matlab ...Creating random decimal numbers in C - comp.soft-sys.matlab ... Help Non Integer sampling rate conversion c code - comp ... Creating random decimal numbers in C - comp ... How to generate non-repeating random integers - comp.soft-sys ...Hi all, Does anybody know how to generate a series of say 450 non-repeating random integers between 0 and 2000? Thanks ... How to generate non-repeated random integers - comp.soft-sys.sas ...Dear all, My problem is like this. I want to simulate artificial data ranking 15 criteria (C1, .... , C15). So, each observation should have any r... 7/25/2012 1:57:39 AM
|
|
|
|
|
|
|
|
|