BookmarkSubscribeRSS Feed
clancaster
Fluorite | Level 6

I am working on a project and the part I need help on requires:

Data set EMPLOY contains:

ID (employee number),

GENDER, and

 DOB (date of birth).

 

Data set PARTS contains:

PART_NO and

PRICE.

 

Data set SALES contains:

ID (employee number),

TRANS (transaction number),

PART_NO, and

QUANTITY (for each sales call completed).

 

Write a SAS program to read the data sets and

  1. A listing, sorted by ID, showing ID, the transaction number, and the total sale for each transaction.

I have managed to multiply quantity with price in order to get total sales but I am missing a few values so I know I didn't sort it the right way. I am at a dead end at this point and will appreciate the help.

 

Here's my code thus far:

 

libname datain 'F:\SAS2018\Data';

/***********************************************************************/

data employ_ds;
set datain.employ;
run;

proc print data=employ_ds;
format ID z2. Bday MMDDYY8.;
run;

/***********************************************************************/
data parts_ds;
set datain.parts;
run;

proc print data=parts_ds;
format price dollar6.2;
run;

/***********************************************************************/
data sales_ds;
set datain.sales;
run;

proc print data=sales_ds;
run;
/***********************************************************************/
data transaction_sales;
merge datain.sales datain.parts;
total= quantity*price;
run;

proc sort data=transcation_sales;
by ID;
run;

proc print data=transaction_sales;
format ID z2. ;
run;
/***************************************************************************************/

 

 

 

 

 

1 REPLY 1
Reeza
Super User
Your MERGE is likely wrong. You most likely want a BY statement.

If you can’t figure out the code, use the Tasks and steal the code from the log or in the task itself.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 754 views
  • 0 likes
  • 2 in conversation