I have two datasets data1
and data2
with an id
column. I want to assign a random id to each id, but this random number needs to be consistent across datasets. (rand_id
for id=1
must be the same in both datasets). The objective is to get:
id | rand_id |
---|---|
1 | 0.4212 |
2 | 0.5124 |
3 | 0.1231 |
id | rand_id |
---|---|
1 | 0.4212 |
3 | 0.1231 |
2 | 0.5124 |
4 | 0.9102 |
I thought
DATA data1;
SET data1;
CALL STREAMINIT(id);
rand_id=RAND('uniform');
RUN;
and the same for data2
would do the job, but it does not. It just takes as seed the first id and generates a sequence of random numbers. From the STREAMINIT documentation, it seems it's only called once per data setp. I'd like to be called it in every row. Is this possible?
Aucun commentaire:
Enregistrer un commentaire