The SAS Output Delivery System and reporting techniques

How to set a user-generated ID's to a set of values

Reply
N/A
Posts: 0

How to set a user-generated ID's to a set of values

Hi,
By making connection to a database in SAS, I can select particular columns from a table and this process continues for a set of time periods and all data is meged. Now I want to select a random generated ID's for each and every row that was selected, when I query the final data set.

How to get this?

thanks,
N/A
Posts: 0

Re: How to set a user-generated ID's to a set of values

Posted in reply to deleted_user
Hope I understand what your after.

One way:

DATA two;
SET one;
id = Uniform(0); * this will generate pseudo random numbers;
RUN;

* sort on the random numbers;
PROC SORT DATA=two;
BY id;


DATA three;
SET two(OBS=100); *** pick 100 "random" observations ;
RUN;

If you have the STAT package, PROC SURVEYSELECT is excellent and very versatile.
.
The above could be replaced by the following:

PROC SURVEYSELECT DATA=one METHOD=srs N=100 OUT=three;
RUN;
N/A
Posts: 0

Re: How to set a user-generated ID's to a set of values

Posted in reply to deleted_user
That worked, but giving random numbers.

I used id=_N_, which gave observation number as id.

thanks,
N/A
Posts: 0

Re: How to set a user-generated ID's to a set of values

Posted in reply to deleted_user
Also, below one worked:

id1='000'||left(put(_N_,best10.))

thanks
Ask a Question
Discussion stats
  • 3 replies
  • 94 views
  • 0 likes
  • 1 in conversation