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

Hi there!

 

So I had to make three temporary data sets in one data step as well as create a new variable named ShipDays (that is the number of days between when the order was placed and when the order was delivered). I got this part done no problem.. 

 

But then it asks to : Output to ‘QUICK’ when the value of ShipDays is less than 3.

Output to ‘SLOW’ when the value of ShipDays is 3 to 5.

Output to ‘VERYSLOW’ when the value of ShipDays is greater than 5. 

 

this is what i have:

 

data quick
slow
veryslow;

set orders;

where Order_Type_Label in ("Web", "Catalogu");

ShipDays = Delivery_Date - Order_Date;

 

run;

 

How do I do this? IF THEN statement? but I'm not sure what to put after THEN. thanks for any help 🙂

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21
data quick
 slow
 veryslow;
  set orders;
  where Order_Type_Label in ("Web", "Catalogu");
  ShipDays = Delivery_Date - Order_Date;
  if ShipDays lt 3 then output quick;
  else if Shipdays le 5 then output slow;
  else if Shipdays gt 5 then output veryslow;
run;

Art, CEO, AnalystFinder.com

 

View solution in original post

6 REPLIES 6
art297
Opal | Level 21
data quick
 slow
 veryslow;
  set orders;
  where Order_Type_Label in ("Web", "Catalogu");
  ShipDays = Delivery_Date - Order_Date;
  if ShipDays lt 3 then output quick;
  else if Shipdays le 5 then output slow;
  else if Shipdays gt 5 then output veryslow;
run;

Art, CEO, AnalystFinder.com

 

sammydouglas
Calcite | Level 5
oh thank you! I did not know there was an output function. kinda embarrassing 😛
art297
Opal | Level 21

FYI: output is a statement .. not a function. All functions are in the form functionname()

 

Art, CEO, AnalystFinder.com

 

Reeza
Super User

@sammydouglas wrote:

Hi there!

 

So I had to make three temporary data sets in one data step as well as create a new variable named ShipDays (that is the number of days between when the order was placed and when the order was delivered). I got this part done no problem.. 

 

But then it asks to : Output to ‘QUICK’ when the value of ShipDays is less than 3.

Output to ‘SLOW’ when the value of ShipDays is 3 to 5.

Output to ‘VERYSLOW’ when the value of ShipDays is greater than 5. 

 

this is what i have:

 

data quick
slow
veryslow;

set orders;

where Order_Type_Label in ("Web", "Catalogu");

ShipDays = Delivery_Date - Order_Date;

 

run;

 

How do I do this? IF THEN statement? but I'm not sure what to put after THEN. thanks for any help 🙂


 

atul_desh
Quartz | Level 8

data Quick1(where=(ShipDays<3)) Slow (where=(3<=ShipDays<5)) veryslow (where=(ShipDays>5));
set orders;
where Order_Type_Label in ("Web", "Catalogu");
ShipDays = Delivery_Date - Order_Date;
run;

Cynthia_sas
SAS Super FREQ
Also, remember to double check your data for the correct values of Order_Type_Label. "Catalogu" is an odd spelling for either Catalogue or Catalog.

And, if you are using the ORDERS dataset from PROGRAMMING 2, there is an exercise very simliar to this one in Chapter 2, page 2-19/20 and the solution to the exercise is on page 2-50.

cynthia

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
  • 6 replies
  • 1122 views
  • 1 like
  • 5 in conversation