Programming the statistical procedures from SAS

How do I get a column of observation id?

Reply
New Contributor
Posts: 4

How do I get a column of observation id?

I need x to = 1 - 178 (observations). So far my commands are:

 

/* transform consumption and income variables into logs*/

data session3.combinedfiles;
set session3.combinedfiles;

y=log(PCECC96);
x1=log(DPIC96);
x2=log(MPRIME);
run;

 

/* multiple regression model: suppose Y now depends on x1 and x2: Y = beta0+ beta1 x1 + beta2 x2 + error*/

proc reg data=session3.combinedfiles;
model y = x1 x2;
output out=session3.est_data1 residual=e predicted=y_hat lcl=lower95 ucl=upper95;
run;
quit;

 

As you can see I don't have a column called X which simply equals id. Thank you for the help.

Attachment
Respected Advisor
Posts: 4,606

Re: How do I get a column of observation id?

Simply add a statement:

 

/* transform consumption and income variables into logs*/
data session3.combinedfiles;
set session3.combinedfiles;
y=log(PCECC96);
x1=log(DPIC96);
x2=log(MPRIME);
ID=_n_;
run;
PG
New Contributor
Posts: 4

Re: How do I get a column of observation id?

I still don't have a column that says X and under it the numbers from 1 through 178.

Attachment
Respected Advisor
Posts: 4,606

Re: How do I get a column of observation id?

Something went wrong. Check the log. You should have a new column called ID in your OUT= dataset.

PG
SAS Super FREQ
Posts: 3,310

Re: How do I get a column of observation id?

If you want the variable to be named x, then use

x = _n_;

Ask a Question
Discussion stats
  • 4 replies
  • 229 views
  • 0 likes
  • 3 in conversation