Date: Thu, 21 Dec 2006 12:28:55 -0500
Reply-To: Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Subject: Re: Linking 2 datasets
Jared,
best thing I think, is to generate a format from your name-dataset.
I don't know the type of your site id, I assume it is char. So you should
define a format like:
proc format lib=library;
label $site
"1" = "Elmo"
"2" = "Ernie"
"3" = "Bert"
"4" = "Oscar";
run;
If you have many names in a dataset, don't retype them, but use:
data cntlin;
length start $8 label $10;
set your_dataset;
fmtname="SITE";
type = "C";
start = siteID;
label = name;
run;
proc format lib=library cntlin=cntlin;
run;
This format you assign to siteID wherever you want the long names to occure
in a report. For changes you have only to rerun the format generation.
Another possibility is the generation of a view which merges the 2 datasets
by siteID. But a format is much faster and more elegant for that.
Regards,
Gerhard
On Thu, 21 Dec 2006 09:02:31 -0800, webonomic <webonomic@GMAIL.COM> wrote:
>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