BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
aabbccwyt
Obsidian | Level 7

Hi. I have the following code in SAS

data have;

input Make $ Model $ Type $ Origin $ DriveTrain $ MSRP Invoice;
datalines;
Acura MDX SUV Asia All 36945 33337
BMW X3 SUV Europe All 37000 33873
BMW 325i Sedan Europe All 52195 47720
Dodge Durango SUV USA All 32235 29472
Dodge Neon Sedan USA Front 13670 12849
;

pct_change = (MSRP - Invoice)/Invoice;
format pct_change percent10.;
where Type = "SUV" and DriveTrain = "All";
run;

proc print data = have;
title 'All wheel drive SUVs with less than 10% change in Price';
var Make Model MSRP Invoice pct_change;
where pct_change le 0.1;
run;

and I'm receiving the following errors

80         pct_change = (MSRP - Invoice)/Invoice;
            __________
            180
 
 ERROR 180-322: Statement is not valid or it is used out of proper order.

I don't know what I have done wrong and this should be a simple code so it really confused me. Any help? Thank you in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

Compare below syntactically working code to your version and you should understand where you've got it wrong.

data have;
  input Make $ Model $ Type $ Origin $ DriveTrain $ MSRP Invoice;
  pct_change = (MSRP - Invoice)/Invoice;
  format pct_change percent10.;
  if Type = "SUV" and DriveTrain = "All";
  datalines;
Acura MDX SUV Asia All 36945 33337
BMW X3 SUV Europe All 37000 33873
BMW 325i Sedan Europe All 52195 47720
Dodge Durango SUV USA All 32235 29472
Dodge Neon Sedan USA Front 13670 12849
;

proc print data = have;
  title 'All wheel drive SUVs with less than 10% change in Price';
  var Make Model MSRP Invoice pct_change;
  where pct_change le 0.1;
run;

View solution in original post

2 REPLIES 2
Patrick
Opal | Level 21

Compare below syntactically working code to your version and you should understand where you've got it wrong.

data have;
  input Make $ Model $ Type $ Origin $ DriveTrain $ MSRP Invoice;
  pct_change = (MSRP - Invoice)/Invoice;
  format pct_change percent10.;
  if Type = "SUV" and DriveTrain = "All";
  datalines;
Acura MDX SUV Asia All 36945 33337
BMW X3 SUV Europe All 37000 33873
BMW 325i Sedan Europe All 52195 47720
Dodge Durango SUV USA All 32235 29472
Dodge Neon Sedan USA Front 13670 12849
;

proc print data = have;
  title 'All wheel drive SUVs with less than 10% change in Price';
  var Make Model MSRP Invoice pct_change;
  where pct_change le 0.1;
run;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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