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 (March 2008, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 25 Mar 2008 15:21:57 +0000
Reply-To:     toby dunn <tobydunn@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         toby dunn <tobydunn@HOTMAIL.COM>
Subject:      Re: Global Variable Creation
Comments: To: sonik son <sonikson@gmail.com>
In-Reply-To:  <baab6052-ac3f-4916-9b27-641f5f873c19@a23g2000hsc.googlegroups.com>
Content-Type: text/plain; charset="iso-8859-1"

sonik ,

It didnt require too much time on my part. I tested the code on my machine at home running windows 9.1.3 sp4 using Windows XP. Everything worked fine when I ran my code. I would make sure that Options NoXSync NoXWait are used and then look at the code you are submitting to yoru operating system via the call system routines.

Toby Dunn

"Don't bail. The best gold is at the bottom of barrels of crap." Randy Pausch

"Be prepared. Luck is where preparation meets opportunity." Randy Pausch

> Date: Tue, 25 Mar 2008 08:09:22 -0700 > From: sonikson@GMAIL.COM > Subject: Re: Global Variable Creation > To: SAS-L@LISTSERV.UGA.EDU > > On Mar 24, 8:39 pm, tobyd...@HOTMAIL.COM (toby dunn) wrote: >> This is from a paper I am working on for SESUG coming up. >> >> It uses no macro variables and does not split your data up, but rather processes your data as is and creates three CSV files one for each country in the SASHELP data set I used. >> >> Options NoXSync NoXWait ; >> >> /*******************/ >> /** Create Some Data **/ >> /*******************/ >> Proc Summary >> Data = SASHELP.prdsal3 NWay ; >> Class Country State ; >> Output Out = Sums ( Drop = _Freq_ _Type_ ) Sum( Actual ) = Sales ; >> Run ; >> >> /************************/ >> /** Output One File For Each **/ >> /** Value Of Country **/ >> /************************/ >> ODS Listing Close ; >> ODS NoResults ; >> ODS CSV File = "C:\Documents and Settings\Toby Dunn\Desktop\Test\Country1.CSV" >> NewFile = ByGroup ; >> >> Proc Print >> Data = Sums NoObs ; >> By Country ; >> Var Country State Sales ; >> Run ; >> >> ODS CSV Close ; >> ODS Listing ; >> >> /**************************/ >> /** Rename Each File So That **/ >> /** Each File Is Named For The **/ >> /** Country It Contains. **/ >> /*************************/ >> >> Data _Null_ ; >> Set Sums ; >> By Country ; >> >> If First.Country Then Do ; >> Cnt + 1 ; >> OldName = CatS( "Country" , Cnt , ".CSV" ) ; >> NewName = CatS( Country , ".CSV" ) ; >> Call System( "CD C:\Documents and Settings\Toby Dunn\Desktop\Test" ) ; >> Call System( CatX( " " , "Rename" , OldName , NewName ) ) ; >> End ; >> >> Run ; >> >> Toby Dunn >> >> "Don't bail. The best gold is at the bottom of barrels of crap." >> Randy Pausch >> >> "Be prepared. Luck is where preparation meets opportunity." >> Randy Pausch >> >> >> >> >> >>> Date: Mon, 24 Mar 2008 08:47:24 -0700 >>> From: sonik...@GMAIL.COM >>> Subject: Global Variable Creation >>> To: SA...@LISTSERV.UGA.EDU >> >>> I've read through the numerous posts on creating global variables >>> here, but have been unable to create code that works for me. So, here >>> we go. >> >>> I've been tasked with a new process which involves generating a >>> dataset of customer accounts from our 50 branches, then sending as >>> list each branch's accounts to them. This is a weekly process and not >>> every branch will have accounts any given week. >> >>> My weekly branch account dataset is roughly set up in this fashion: >> >>> data branches; >>> input branch_id account_nbr; >>> datalines; >>> 802 10025 >>> 802 10034 >>> 806 44135 >>> 806 95622 >>> 811 11337 >>> ; >> >>> I'd like to set up a process whereby I can automatically read the >>> branch_id's which appeared on the weekly report, create a dataset of >>> accounts for that branch_id (named for each branch_id, e.g. >>> "work.br802", work.br806", "work.br811",) then export them to Excel. >>> Currently, this is a manual process (and it is killing me.) I have >>> experimented using CALL SYMPUT and CALL EXECUTE examples from old SUGI >>> papers, but I have not been able to successfully translate those >>> approaches to my particular issue. >> >>> I appreciate any input or guidance any has to offer. >> >> _________________________________________________________________ >> Test your Star IQhttp://club.live.com/red_carpet_reveal.aspx?icid=redcarpet_HMTAGMAR- Hide quoted text - >> >> - Show quoted text - > > First, thank you for replying, Toby. I appreciate that this plee > required some significant legwork to solve, which is why I came to the > mighty SAS-Lers. > > The code you recommend above works swimmingly, save for the DATA > _NULL_ statement. Using the SASHELP.prdsal3 table as a test, the code > responds as intended for the first country in the dataset, "Canada," > but does not appear to continue running for the others. (I gave the > data step 3-4 mins to run. Too little time? Canada seemed to be > renamed right away.) > > Could this be due to the 'If First.Country Then Do ;' clause?

_________________________________________________________________ Windows Live Hotmail is giving away Zunes. http://www.windowslive-hotmail.com/ZuneADay/?locale=en-US&ocid=TXT_TAGLM_Mobile_Zune_V3


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