turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- ODS and Base Reporting
- /
- How to set a user-generated ID's to a set of value...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

09-11-2007 03:52 PM

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,

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,

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to deleted_user

09-11-2007 06:43 PM

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;

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;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to deleted_user

09-13-2007 10:52 AM

That worked, but giving random numbers.

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

thanks,

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

thanks,

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to deleted_user

09-13-2007 10:58 AM

Also, below one worked:

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

thanks

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

thanks