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 01:39:47 +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:   <885fe238-8079-44eb-9688-d15543b23dfb@e67g2000hsa.googlegroups.com>
Content-Type:   text/plain; charset="iso-8859-1"

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: sonikson@GMAIL.COM > Subject: Global Variable Creation > To: SAS-L@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 IQ http://club.live.com/red_carpet_reveal.aspx?icid=redcarpet_HMTAGMAR


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