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 (December 2006, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 21 Dec 2006 17:17:20 +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: Linking 2 datasets
Comments:   To: webonomic@GMAIL.COM
In-Reply-To:   <1166720551.477476.170140@n67g2000cwd.googlegroups.com>
Content-Type:   text/plain; format=flowed

Webonic ,

Make your second data set a format, this can be done via proc format and a cntlin data set:

Data One ; Input SiteID Name $ ; Cards ; 1 Elmo 2 Ernie 3 Bert 4 Oscar ; run ;

Data MyFmt ; Set One ( rename = ( SiteId = Start Name = Label ) ) ; Retain FMTNAME 'SiteName' Type 'N' ; Run ;

Proc Format Library = Work CntLIn = MyFmt ; Run ;

Data _Null_ ; Do I = 1 To 4 ; New = Put( I , SiteName. ) ; Put New= ; End ; Run ;

Now if your your site name data set changes so will your output. If you have your code written right and your data structure properly contrsuted what you end up with is little if any at all hard coded values. Thus your code should reflect the business logic only leaving the reader in a better state and you in an even better state since the code can handle all changes except business logic and starting data structure changes.

Toby Dunn

To sensible men, every day is a day of reckoning. ~John W. Gardner

The important thing is this: To be able at any moment to sacrifice that which we are for what we could become. ~Charles DuBois

Don't get your knickers in a knot. Nothing is solved and it just makes you walk funny. ~Kathryn Carpenter

From: webonomic <webonomic@GMAIL.COM> Reply-To: webonomic <webonomic@GMAIL.COM> To: SAS-L@LISTSERV.UGA.EDU Subject: Linking 2 datasets Date: Thu, 21 Dec 2006 09:02:31 -0800

I have 2 datasets:

Dataset1: SiteID Q1 Q2 1 2.3 11002 2 4.7 39209 1 1.2 20983 3 2.2 40989 2 0.2 23492 4 0.7 10983 4 0.9 77549 3 2.1 29403 3 3.0 84302

Dataset2: SiteID Name 1 Elmo 2 Ernie 3 Bert 4 Oscar

(My real datasets have more observations and more variables.)

Table 2 is only really used for Reporting purposes. Ie. to make reports more readable, I want to use the Name rather than the SiteID.

What I usually do is create a Name variable in Dataset1 permanently and work with this permanent dataset. It works, but if the Name ever changes, I have re-run some programs to update the dataset. This does not seem ideal. I don't like hardcoding it into the dataset, nor would I want to create this variable everytime I want to do data analysis.

So when I do Proc Tabulate or Proc Report and other procs on Dataset1, what methods are available to pull in the Name from Dataset2? Should I continue doing it the way I am used to? How do other people solve this?

TIA,

Jared

_________________________________________________________________ Your Hotmail address already works to sign into Windows Live Messenger! Get it now http://clk.atdmt.com/MSN/go/msnnkwme0020000001msn/direct/01/?href=http://get.live.com/messenger/overview


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