BookmarkSubscribeRSS Feed
FLETCHSAS
Calcite | Level 5

Hello all,

     I have been trying to rename the numeric variable 'Price S' to just 'price' but for some reason this variable, along with 'Price US', produce error messages when I run the program. I have been able to change carat car, colorcol, and certificationcert. Below is the code I am running. If anyone can help it would be greatly appreciated, Thank you.


PROC IMPORT datafile="/home/michaelfletcher/FletcherSAS/WORK/DATA/Diamonds.xls"

     OUT=WORK.Diamonds

     DBMS=xls

     REPLACE;

RUN;

DATA diam;

     SET Diamonds;

RUN;

DATA diam (rename=(carat=car color=col certification=cert Price_S=price));

     SET diamonds;

RUN;

PROC CONTENTS data=diam;

RUN;

--Michael Fletcher

7 REPLIES 7
ballardw
Super User

Please supply the error messages. They are often very helpful in diagnosing problems.

Also if there are any warnings in the log or notes related to encoding.

woo
Lapis Lazuli | Level 10 woo
Lapis Lazuli | Level 10

looks nothing wrong with DATA STEPS in your code. below code works fine so do yours too...check variable name for your input dataset in rename step

data a;

   carat=123;

   color=345;

   certification=56789;

   price_s=465789;

   run;

data b (rename=(carat=car color=col certification=cert Price_s=price));

set a;

run;

what is your error message ?

FLETCHSAS
Calcite | Level 5

No ERROR messages. The proc contents still shows the same variable name and I get this warning message:

WARNING: The variable Price_S in the DROP, KEEP, or RENAME list has never been referenced.

ballardw
Super User

This means that the way you typed Price_S doesn't quite match what the name of the variable actually is. Copy it from the proc contents output and paste that into the code. I suspect there may be two or more _ in the actual name together and it just looks like one.

FLETCHSAS
Calcite | Level 5

When I copy & paste ''Price S" it returns this error message:

ERROR 79-322: Expecting a =.

ballardw
Super User

Show us the proc contents output.

And the code that generated the error.

SASKiwi
PROC Star

"Price S" is not a valid SAS variable name so you may need to do the rename like this: (rename = ('Price S'n = Price))

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 7 replies
  • 3949 views
  • 10 likes
  • 4 in conversation