Date: Fri, 1 Nov 2002 15:56:23 -0500
Reply-To: "Fehd, Ronald J. (PHPPO)" <rjf2@CDC.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Fehd, Ronald J. (PHPPO)" <rjf2@CDC.GOV>
Subject: Re: looking to see if there is an alt way to merge data sets
Content-Type: text/plain
> From: Edgar Sanchez [mailto:Suppression@MAIL.UTEXAS.EDU]
> I was trying to merge multiple data sets with a single
> observation into a new data set with a single observation
> with the variables from the individual data sets. What
> follows is my first attempt which i would like to see if any
> one can help me get working followed by the way that i am
> doing it currently (which is a matched merge). I initially
> tried to do this with a set command:
> data final;
> set bias rmseout sdm stdzdrmse aadiff avgtheta
> correl(keep=thet); rename thet=correl; drop _TYPE_ _FREQ_
> n_t n_se n_nia; run;
pretty tricky stuff, I'll suggest:
you create the output structure you want with the attrib statement.
retain carries forward the values from each of the data sets.
after you read in the series of data sets,
when you reach the last one, your observation is loaded, therefore output;
data final;
%*if these are real, then length=8
else if integer then length=4;
attrib diff length = 8
rmse length = 8
sdm length = 8
srmsd length = 8
absdiff length = 8
std_t length = 8
std_se length = 8
std_nia length = 8
theta_est length = 8
;
retain diff
rmse
sdm
srmsd
absdiff
std_t
std_se
std_nia
theta_est 0;%*trick1;
set bias
rmseout
sdm
stdzdrmse
aadiff
avgtheta
correl (in = HaveCorrel)%*trick2;
;
if HaveCorrel then output;
Structure is everything in whizardry.
Ron Fehd the macro maven CDC Atlanta GA USA RJF2@cdc.gov
--> cheerful provider of UNTESTED SAS code from the Clue?Gee!Wrx <--
By using your intelligence
you can sometimes make your problems twice as complicated.
-- Ashleigh Brilliant
> So this gave me the following data set:
> Obs diff rmse sdm srmsd absdiff std_t std_se
> std_nia theta_est
>
> 1 0.010075 . . . . .
> . . .
> 2 . 0.63640 . . . .
> . . .
> 3 . . -.00917922 . . .
> . . .
> 4 . . . 0.72684 . .
> . . .
> 5 . . . . 0.35110 .
> . . .
> 6 . . . . . 1.16282
> 0.066060 0 -.00655667
> 7 . . . . . .
> . . .
>
> std_
> Obs error avg_nia min_t min_se min_nia max_t max_se
> max_nia correl
>
> 1 . . . . . .
> . . .
> 2 . . . . . .
> . . .
> 3 . . . . . .
> . . .
> 4 . . . . . .
> . . .
> 5 . . . . . .
> . . .
> 6 0.30208 20 -3.671 0.263 20 3.639
> 1.064 20 .
> 7 . . . . . .
> . . 0.83808
> I was looking for a way to reduce this data set matrix, if
> you will, and I wanted to reduce these into a single
> observation. I couldn't get this method to work for me so i
> gave in and set up a common variable in ever data set and
> merged as follows:
>
> data final;
> merge bias rmseout sdm stdzdrmse aadiff avgtheta correl;
> by sort;
> rename thet=correl;
> run;
>
> data /*grm2002.*/final2; set final(drop=_freq_ _type_ n_t
> n_se n_nia std_nia sort);run;
>
> This finally gave me what i needed. I got the single
> observation this way, but was hoping there was a wy to do
> this other than by a matched merge. The more data sets I
> merge the more ungainly this process of creating a var in
> every data step will be. This matching var can be useful for
> me as a label for my various conditions. I am using a perm
> data set have a single obs per condition (resulting from
> different sas programs. I would rather merge or combine
> before this creation so that I can just create this condition
> label only once as opposed to once per dataset to be merged.
>
> Any ideas you have would be appreciated. I asked my fellow
> grad students, but they got hung up in pretty much the same
> manner I did. Im hoping the more experienced users here can
> help. Thanks in advance.
>