Date: Mon, 11 Nov 1996 13:18:09 +0500
Reply-To: Bernard Tremblay <bernard@CAPITALE.QC.CA>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Bernard Tremblay <bernard@CAPITALE.QC.CA>
Subject: Re: Help ! Retaining a value...
You should not merge the two datasets. Try to read the first one
at the start of your datastep and then read the second one (the one with
if _n_ =1 then set first;
This should work ok if you don't have the same variables name
in first and second; otherwise rename your variable in one .
\\ - - //
( @ @ )
| Bernard Tremblay | Bureau: (418) 646-2401 |
| La Capitale | Maison: (418) 878-4447 |
| |Internet: email@example.com |
| | firstname.lastname@example.org |
oooO ( )
( ) ) /
\ ( (_/
>>>From owner-sas-l@UGA.CC.UGA.EDU Mon Nov 11 11:46 EST 1996
>>>Date: Tue, 5 Nov 1996 01:30:22 -0600
>>>From: Slowhand <slowhand@UIUC.EDU>
>>>Subject: Help ! Retaining a value...
>>>To: Multiple recipients of list SAS-L <SAS-L@UGA.CC.UGA.EDU>
>>>I have the following problem :
>>>My overall objective is this : I have two datasets. From one dataset,
>>>I want to compute a median, etc, and
>>>use this value in a formula that has variables from a second data
>>>set. ie, in the formula, there will be observations (2000 of them)
>>>read from the second data set, and I want to use the median I calculated
>>>from the first data set and calculate a new variable based on the
>>>formula. The new variable will thus have 2000 observations itself.
>>>The problem I have is regarding using the median value I calculate
>>>from the first dataset in the formula. I use proc univariate to
>>>calculate the median from the first dataset, and save it to an output
>>>file (thus this output file has exactly one observation). Now I open
>>>a new dataset of 2000 observations, and I want to use the median
>>>value I calculated above, in conjunction with each of the 2000
>>>observations, one at a time to create a new variable based on the
>>>formula. But the problem is, the data set with the median value in it
>>>has one observation while the other dataset has 2000 observations.
>>>When I use merge, it just puts missing values for the median in the
>>>rest of 1999 observations.
>>>The only way I know right now to handle this is to use two different
>>>programs - first calculate the median, then manually write it down.
>>>and plug in that written down value as a parameter in the second
>>>program. But this is terribly inefficient !
>>>Any help would be greatly appreciated.
>>>Thanks in advance,