BookmarkSubscribeRSS Feed
khalillx
Fluorite | Level 6

Anyone know what's wrong with my code that I'm getting this error message in my log?:

 

15 PCE0 = PCE/6712.166667;
----
180

ERROR 180-322: Statement is not valid or it is used out of proper order.

116 RGAS = Price/PCE0;
----
180

 

So I have to find the real price of gas and I found the average price of my deflator in my excel file of the year 2000 which is my base year which turned out to be 6712.166667. I was given this code to use to create my new variable of the real price of gas but it's not working. I have never done this before so I'm not sure what to do. Here is my code getting the error message:

 

PCE0 = PCE/6712.166667;
RGAS = Price/PCE0;

 

This is my full code:

ODS LISTING;
libname session1 "x";

PROC IMPORT OUT= WORK.one
DATAFILE="x"
DBMS=csv REPLACE;
RUN;


proc print data= WORK.one;
run;

proc contents;
run;

PCE0 = PCE/6712.166667;
RGAS = Price/PCE0;

 

I hid my pathway.

4 REPLIES 4
Reeza
Super User
You have to post the full code and log, not just the error. That being said, I'll bet the error is actually before that line, and is a missing semicolon again.
khalillx
Fluorite | Level 6
You want my full log? That's a lot of information. I copied my code exactly from my professor so I doubt it's that.
Reeza
Super User

You can't access variables like that. To create a new variable it needs to be within a data step. 

 

You're essentially creating new variables. 

 

Here's a video tutorial that covers the topic:

 

https://video.sas.com/detail/videos/sas-analytics-u/video/4573023399001/creating-a-new-column-in-sas...

 

And yes, you need to provide enough code and the log for us to help you. Posting partial code hides the issues, especially when it's something as big as not using a data step. 

 


@khalillx wrote:

Anyone know what's wrong with my code that I'm getting this error message in my log?:

 

15 PCE0 = PCE/6712.166667;
----
180

ERROR 180-322: Statement is not valid or it is used out of proper order.

116 RGAS = Price/PCE0;
----
180

 

So I have to find the real price of gas and I found the average price of my deflator in my excel file of the year 2000 which is my base year which turned out to be 6712.166667. I was given this code to use to create my new variable of the real price of gas but it's not working. I have never done this before so I'm not sure what to do. Here is my code getting the error message:

 

PCE0 = PCE/6712.166667;
RGAS = Price/PCE0;

 

This is my full code:

ODS LISTING;
libname session1 "x";

PROC IMPORT OUT= WORK.one
DATAFILE="x"
DBMS=csv REPLACE;
RUN;


proc print data= WORK.one;
run;

proc contents;
run;

PCE0 = PCE/6712.166667;
RGAS = Price/PCE0;

 

I hid my pathway.


 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 4 replies
  • 698 views
  • 0 likes
  • 3 in conversation