BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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,
3 REPLIES 3
deleted_user
Not applicable
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;
deleted_user
Not applicable
That worked, but giving random numbers.

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

thanks,
deleted_user
Not applicable
Also, below one worked:

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

thanks

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 633 views
  • 0 likes
  • 1 in conversation