BookmarkSubscribeRSS Feed
jonty
Fluorite | Level 6

here i want to change the variable from char to numeric so i used input and i gave the format as well and i want to get the simplest way to create it. 

 

 

code :-

 

data carz;
set work.import
(rename= (MSRP = MSRP1,Invoice = Invoice1));
MSRP = input(MSRP1, dollar12.);
Invoice = input(Invoice1, dollar12.);
format Invoice Dollar12.;
format MSRP Dollar12.;
drop MSRP1 Invoice1;
run;

 

 

log errors :-

 

data carz;
64 set work.import
65 (rename= (MSRP = MSRP1,Invoice = Invoice1));
_
214
23
_______
79
ERROR 214-322: Variable name , is not valid.
 
ERROR 23-7: Invalid value for the RENAME option.
 
ERROR 79-322: Expecting a =.
 
66 MSRP = input(MSRP1, dollar12.);
67 Invoice = input(Invoice1, dollar12.);
68 format Invoice Dollar12.;
69 format MSRP Dollar12.;
70 drop MSRP1 Invoice1;
71 run;
 
 
 
2 REPLIES 2
Jagadishkatam
Amethyst | Level 16

I believe there is a correction required in the rename option, no comma is required to rename two or more variables. Please try the updated code

 

 

data carz;
set work.import(rename= (MSRP = MSRP1 Invoice = Invoice1));
MSRP = input(MSRP1, dollar12.);
Invoice = input(Invoice1, dollar12.);
format Invoice MSRP  Dollar12.;
drop MSRP1 Invoice1;
run;
Thanks,
Jag
ballardw
Super User

If you post the log into a code box opened using the forum {i} menu icon then the text format will be as in your log. As pasted into a message window the forum removes most of the leading spaces. So the underscore of error message that should have appeared under the comma, indicating that was where SAS found an error in the syntax, is not in the correct place.

Note that the text is telling you the same thing:  Variable name , is not valid.

 comma is not a valid variable name.

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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