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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 1 reply
  • 645 views
  • 0 likes
  • 2 in conversation