Help using Base SAS procedures

Proc reg with categorical variables 0/1

Reply
Occasional Contributor
Posts: 11

Proc reg with categorical variables 0/1

Hi, 

 

Edition= Sas University Edition(9.4)

procedue=proc reg

data used contains categorical varaibles as 0/1 

 

code used=

 

proc reg data=Mylib.lineaf;
model revenue=Units_Sold Price mid tro dom;
output out=mylib.result predicted=p residual=r;
run;

 

/*where mid tro and dom contains varaibles as 0/1*/

 

Result encountering

 

The REG Procedure

  Number of Observations 89

Read Number of Observations 0

Used Number of Observations with Missing Values 89

 

 

But no further results are published  

Please help. not getting where exactly I am committing an error.

Super User
Posts: 11,343

Re: Proc reg with categorical variables 0/1

Your issue comes from this message: Used Number of Observations with Missing Values 89

 

The procedure requires all variables on the model statement to be present. Any record that has one or more values missing for any of the independent variables is dropped from the calculation.

Apparently every record you have has at least one missing value for the independent variables in the model.

 

Occasional Contributor
Posts: 11

Re: Proc reg with categorical variables 0/1

But the output data shows that each of these variables mid tro dom are filled with either 0/1.I am not getting where the variables are missing
Super User
Posts: 19,877

Re: Proc reg with categorical variables 0/1

One of the variables is missing for every observation. It doesn't have to be the variables you mentioned.

 

Run a proc means on your data to see which variables have missing values.

 

proc means data=have n nmiss;

run;

Occasional Contributor
Posts: 11

Re: Proc reg with categorical variables 0/1

I think every 0 in my variable data is appearing as missing variable.how to deal with it
Super User
Posts: 19,877

Re: Proc reg with categorical variables 0/1

Fix your input data - if it should be 0, make sure it's 0, if it should be missing make sure it's missing.

 

It's possible that somehow the MISSING option is set to 0, but you would have to have explicitly changed the setting. See the line of code below to reset the values.

 

 

options missing=.;

 

Occasional Contributor
Posts: 11

Re: Proc reg with categorical variables 0/1

Yes I used this line in my previous code but later formatted them using format statement as nuemerics...i felt it worked but it seems it didnt....noe tell me how to breakthrough it
Super User
Posts: 19,877

Re: Proc reg with categorical variables 0/1


sree0203 wrote:
Yes I used this line in my previous code but later formatted them using format statement as nuemerics...i felt it worked but it seems it didnt....noe tell me how to breakthrough it

Ok. If your problem is resolved mark the question as solved, if not, indicate what the issue is outstanding. If you've tried something that didn't work please let me know.

Super User
Posts: 11,343

Re: Proc reg with categorical variables 0/1


sree0203 wrote:
Yes I used this line in my previous code but later formatted them using format statement as nuemerics...i felt it worked but it seems it didnt....noe tell me how to breakthrough it

Format and option missing display do not change underlying values.

 

something like:

data need;
   set have;
   array a _numeric_;
   do i=1 to dim(a);
      if missing(a[i]) then a[i]=0;
   end;
   drop i;
run;

to actually set the values to 0. Replace _numeric_ with an actual list of numeric variable names if desired.

 

Ask a Question
Discussion stats
  • 8 replies
  • 158 views
  • 0 likes
  • 3 in conversation