Question

I'm new to SAS and more used to R programming and I can't find how to do something quite simple in R : using values stocked in two different datasets in one calculation.

Let's say I have two datasets :

  • Mydata, whith all observations (let's assume I have n observations of one variable, so n rows and 1 column)
  • coefs, whith p coefficients (1 row and p columns)

In R, I could go for something like calculation(Mydata[,1],coefs[1,]) to get an outcome with n rows and 1 column. However, I can't find how to proceed with SAS, given that I can't merge these tables which have not the same dimensions neither any common variable.

I tried things like :

DATA outTable;
Set Mydata coefs;
/* calculation */
run;

or :

DATA outTable;
Set Mydata;
Set coefs;
/* calculation */
run;

but I never get the n-rows outcome I want due to dimension incompatibility.

How should I proceed ?

Was it helpful?

Solution

Try this.

DATA outTable;
Set Mydata;
if _n_=1 then Set coefs;
/* calculation */
run;

Coefs is read in only once, then the values are retained for each row of Mydata.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top