LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (August 2006, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 22 Aug 2006 08:06:00 -0400
Reply-To:     Peter Crawford <peter.crawford@BLUEYONDER.CO.UK>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Peter Crawford <peter.crawford@BLUEYONDER.CO.UK>
Subject:      Re: Need help creating randomly named dataset
Comments: To: Clint Rickards <clinton.rickards@GE.COM>

perhaps it isn't so much trouble.....

when these steps are started within the same session, use no data set name on the data statement! You get a session-controlled unique data set name in the dataN series. (which can be identified after the "run;" by %let that_one = &syslast ; ) For doc, see http://support.sas.com/onlinedoc/913/getDoc/en/lrdict.hlp/a000188132.htm#a0 02503650 (which may wrap. If so, try http://tinyurl.com/hmbfz )

If these steps are not in the same session, there would be no name contention even if their names are the same (while your sessions keep unique control of the library path ... like work )

Perhaps I just don't understand ... but can't see any other need for this randomisation, than uniqueness to support concurrent activity. I can see the situation when two steps could start at exactly the same time. Where for example, these steps are waiting for some event like the existence of a file. I think a random dataset name is a sledge hammer to crack a nut!

Good Luck

peter

On Mon, 21 Aug 2006 15:54:03 -0400, Rickards, Clinton (GE Money) <clinton.rickards@GE.COM> wrote:

>As Mark points out, random numbers can be tricky. You might want to consider using the user id and the SAS system start date/time as part of the data set name: > > >%put &sysuserid &sysdate &systime; >%let new_dsn = work.mydata_&sysuserid._&sysdate._%sysfunc(compress (&systime,":")); >data &new_dsn; >run; > > >I would think the odds of a single user starting 2 SAS sessions at the same time would be remote at best if not impossible. If you are really concerned about it you should check for the existence of the file (using the exist function) and add an additional suffix to make it unique. > >Clint > >-----Original Message----- >From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU]On Behalf Of >Terjeson, Mark (IM&R) >Sent: Monday, August 21, 2006 2:53 PM >To: SAS-L@LISTSERV.UGA.EDU >Subject: Re: Need help creating randomly named dataset > > >Hi, > >I presume you might need a "d" added to >the round() function call. > >The SELECT INTO will leave spaces in the >returned value in the macro variable. >The easiest way to trim leading and >trailing spaces after a SELECT INTO is >to just use the default behavior of the >%LET right afterwards. e.g. > > > >data random ; > x = ranuni(0) ; > x = round(x*10); >run; > >proc sql NOPRINT; > select x into :num1 from work.random; >quit; >%let num1=&num1; * trims leading/trailing spaces ; > >%put >&num1<; > > > > >Depending upon when you run and how you >repeatedly run this, any chance of the same >initial seed getting the same value? If you >need all to be unique you may consider the >suffix to be a timestamp including milliseconds >with all the punctuation taken out. >e.g. DD:HH:MM:SS.SSS as DDHHMMSSSSS > > > > >Hope this is helpful. > > >Mark Terjeson >Senior Programmer Analyst, IM&R >Russell Investment Group > > >Russell >Global Leaders in Multi-Manager Investing > > > > > > > >-----Original Message----- >From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of >rsermer@gmail.com >Sent: Monday, August 21, 2006 11:35 AM >To: SAS-L@LISTSERV.UGA.EDU >Subject: Need help creating randomly named dataset > > >I want to create a randomly named dataset so that I can run multiple >programs at the same time which currently call on modifying the same >dataset... > >SITEBUTTON: >submit; > data random ; > x = ranuni(0) ; > > x=roun(x*10); > run; >endsubmit; >submit continue; > proc sql NOPRINT; > select x into :num1 from work.random; >endsubmit; >submit; > data sasuser.classMAP&num1; set sasuser.tog; > ... > >The sasuser.classMAP&num1 always comes out with spaces after classMAP >and before random number. > >Any suggestions on how to fix this or how to have multiple sessions >running with SAS/AF would be greatly appreciated. > >-Thanks


Back to: Top of message | Previous page | Main SAS-L page