Programming the statistical procedures from SAS

Using data from 2 independent data sets

Reply
Frequent Contributor
Posts: 103

Using data from 2 independent data sets

Hi there my SAS friends:

 

I have a question about solving an function using 2 independent data sets, this because in one of them i have my dependent variable and in the other my independent variables.

 

So, here is what i have:

 

I have accomplished to generate the mean diference between 2 data sets, and further this diference i obtained 3 values a0 b0 and b1, like that:


data dif_want;
merge mean1 mean2;
diff = mean_var_interest1 - mean_var_interest2;
a0 = (mean_var_interest1- mean_var_interest2)/30;
b0 = log(a0/mean_var_interest2);
b1 = b0/10;
run;

 

The next step, to increase the efficience of the solution; i need to use a0 b0 and b1 into this function:

proc nlin data=any_other_dataset plots=all method=marquardt;
parms a0 = a0 b0 = b0 b1 = b1;
model response=a0*exp(exp(b0)*(exp(b1*observation)-1)/b1);
id Sample;
output out=est_ind1 p=pred r=resid parms=a0 b0 b1;
run;

 

I have to write the specifications of the function, being: response and observation that belong to the dataset called 'any_other_dataset'

 

Thank you very much for your suggestions and help.

Respected Advisor
Posts: 4,742

Re: Using data from 2 independent data sets

If you want the values from dif_want as starting values for the nonlinear regression. Use 

 

parms / pdata=dif_want;

PG
Frequent Contributor
Posts: 103

Re: Using data from 2 independent data sets

[ Edited ]

Thank you for your answer but unfortunaly didn't work, in log file appears:

 

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
55
56 proc nlin data=Sem_data_Negat plots=all method=marquardt;
57 parms / pdata=dif_want;
58 where age_in_days >= 0 and age_in_days <= 40;
ERROR: Variable age_in_days is not on file WORK.DIF_WANT.
59 model weight_in_Kilograms=a0*exp(exp(b0)*(exp(b1*age_in_days)-1)/b1);
60 id Animal;
61 output out=est_ind1 p=Peso_Predito1 r=resid parms=a0 b0 b1;
 
thanks
Respected Advisor
Posts: 4,742

Re: Using data from 2 independent data sets

Interesting. I guess you want the WHERE condition to apply to the data from Sem_data_Negat. Try moving the where statement BEFORE the PARMS statement.

PG
Frequent Contributor
Posts: 140

Re: Using data from 2 independent data sets

You need a BY on your MERGE.  This should be the variable that matches between the data sets (ID number or whatever).  If no variable matches between data sets then any results you get will be nonsense.

Respected Advisor
Posts: 4,742

Re: Using data from 2 independent data sets

@plf515, it is not necessarily good practice, but MERGE without BY does exist. It is called One-to-One merging.

 

http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/viewer.htm#a001318478.htm

 

It can be convenient for combining single observation datasets (I know, there are other methods).

PG
Frequent Contributor
Posts: 140

Re: Using data from 2 independent data sets

@PGStats  Yes, I know it exists.  But .... I think I heard this in a SGF talk long ago:

 

If you merge without a by

You'll get strange results and won't know why

SAS Super FREQ
Posts: 3,538

Re: Using data from 2 independent data sets

[ Edited ]

I didn't attend that SGF talk, so I don't know the details, but that statement seems to incite unnecessary worry.  I regularly use MERGE without a BY statement to horizontally concatenate data that I then use to use in creating ODS graphics. (See the end of this article for a discussion.) I've never had a problem.

 

Philosophically, you have to accept that the first observation in data set 'A' might have nothing to do with the first observation in data set 'B'. Of course, I wouldn't do a statistical analysis of the combined data unless I knew that the observations lined up.

 

Perhaps a more fair poem would be:

 

To horizontally concatenate,

MERGE without BY is really great.

But if the variables don't relate,

a statistical analysis is tempting fate.

 

 

Ask a Question
Discussion stats
  • 7 replies
  • 424 views
  • 1 like
  • 4 in conversation