BookmarkSubscribeRSS Feed
Connor11
Calcite | Level 5

I'm trying to merge to data sets into Energy Usage then run a proc reg by state after that. And the code comes back with the Energy Usage table empty and the proc reg failed. Any help would be appreicated!

libname Connor 'F:\Connor SAS\Final Project Econometrics';

data Connor.EnergyTransIncome;
set Connor.EnergyTransIncome; keep State Year Pop PopDens PetBarrels PetBarrelsPC LaneMiles StateGDPPerCapita;
run;

data Connor.Tax;
set Connor.Tax; keep State Gasoline Diesel;
run;

proc sort data= Connor.EnergyTransIncome; out=Connor.EnergyTransIncome_sort;
by State;
run;
proc print data=EnergyTransIncome_sort; run;

proc sort data= Connor.Tax; out=Connor.Tax_sort;
by State;
run;
proc print data= Connor.Tax_sort; run;

data Connor.EnergyUsage;
merge EnergyTransIncome Gastax;
by State;
run;

proc reg data=Connor.EnergyUsage;
model State= Year Pop PopDens LaneMiles StateGDPPerCapita;
run;
6 REPLIES 6
Connor11
Calcite | Level 5

I'm trying to merge to data sets into Energy Usage then run a proc reg by state after that. And the code comes back with the Energy Usage table empty and the proc reg failed. Any help would be appreciated! (Repost from a wrong section)

libname Connor 'F:\Connor SAS\Final Project Econometrics';

data Connor.EnergyTransIncome;
set Connor.EnergyTransIncome; keep State Year Pop PopDens PetBarrels PetBarrelsPC LaneMiles StateGDPPerCapita;
run;

data Connor.Tax;
set Connor.Tax; keep State Gasoline Diesel;
run;

proc sort data= Connor.EnergyTransIncome; out=Connor.EnergyTransIncome_sort;
by State;
run;
proc print data=EnergyTransIncome_sort; run;

proc sort data= Connor.Tax; out=Connor.Tax_sort;
by State;
run;
proc print data= Connor.Tax_sort; run;

data Connor.EnergyUsage;
merge EnergyTransIncome Gastax;
by State;
run;

proc reg data=Connor.EnergyUsage;
model State= Year Pop PopDens LaneMiles StateGDPPerCapita;
run;
ballardw
Super User

From your log copy the Proc Reg code as submitted and any error messages. Paste log into a code box opened with the forum's </> icon to maintain formatting of any error messages. That way we know exactly what is going wrong.

 

But from your description of wanting to do a separate regression for each state the first thing is that STATE should be on a BY Statement. I suspect that your state variable was not numeric which makes it invalid as the dependent variable in a Proc Reg Model statement. The measure you want for a target, such as "Energy Usage" would be the variable on the left side of the equals in the model statement.

 

There is likely to be an issue with YEAR in your model as data across years is quite often highly correlated (i.e. not independent) and thus might require a time series model which would require a procedure from SAS/ETS to properly use the year information.

PaigeMiller
Diamond | Level 26

 

Show us the log, all parts, code, Notes, WARNINGS and ERRORS, with nothing chopped out.

 

And do not post the same question twice.

 
--
Paige Miller
Connor11
Calcite | Level 5

Code.PNGCapture.PNG

Here is a picture of both of those requested. And the only reason why I posted the same question twice was because I noticed posted the question in the wrong section. I apologize for that.

ballardw
Super User

@Connor11 wrote:

Code.PNGCapture.PNG

Here is a picture of both of those requested. And the only reason why I posted the same question twice was because I noticed posted the question in the wrong section. I apologize for that.


We can move posts as needed.

Your second bit with all the errors has answers to your issues. Missing data sets to begin with. I am not sure but I think a few cases you might be confusing source data (goes on the Set statement) and the output data set name (goes on the DATA statement in a data step).

In your proc reg errors where it says "<Variable name" does not match the type" that is because Proc Reg only uses numeric variables. Period. It is the basic simple ordinary least squares regression. Character variables get into one or more of the other regression procedures that will deal with character categorical data.

Reeza
Super User
FYI - I merged your threads as they appear as duplicates.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 677 views
  • 1 like
  • 4 in conversation