Hi,
Another one, Please correct me, if I am wrong
#5- do not know how to get it
/*Scenario:
1.Souj.input24a contains 2 variables, Product and Qty for 20 transactions
2.Souj.input24b contains 2 variables, Product and Price for 20 transactions
3.Create output dataset results.output24
4.Merge data sets Souj.input24a and Souj.input24b one-to-one in order to calculate a new variable
totalprice(=Qtr*Price) for each observation
5. what is the grand total totalprice for the product='screwdriver'?
6.what is the average(mean) totalprice for product='Tape'? */
proc sort data=Souj.input24a out=out.input24a;
by product;
run;
proc sort data=Souj.input24b out=out.input24b;
by product;
run;
data results.output24;
merge out.input24a out.input24b;
by product;
totalPrice=gty*price;
run;
proc means data=results.output24;
by product;
where product='Tape';/* I think #6)
run;
Hi @souji
At first sight it seems that proc means should be:
proc means data=results.output24 mean;
var totalprice;
where product='Tape';
run;
There is also a typo -> gty should be replaced by qty in your code
The very first thing to do would be to try your code!
You will easily see if the syntax is correct and if you get the right results (especially in this case, as there are very few variables and observations).
Thank you for your quick response, I appreciate you
What about : 5. what is the grand total totalprice for the product='screwdriver'?
please help me this too
Souji
IN QUESTION
Merge data sets Souj.input24a and Souj.input24b one-to-one in order to calculate a new variable
totalprice=(Qtr*Price) for each observation
one-to-one merge (using without by statement)
match merge(using by statement)
please can some one explain????????
What part of the documentation do you need an explanation for? Please be specific.
Souj.input24a contains 2 variables, Product and Qty for 20 transactions
2.Souj.input24b contains 2 variables, Product and Price for 20 transactions
3.Create output dataset results.output24
4.Merge data sets Souj.input24a and Souj.input24b one-to-one in order to calculate a new variable
totalprice(=Quantity*Price) for each observation
5. what is the grand total totalprice for the product='screwdriver'?
6.what is the average(mean) totalprice for product='Tape’?
What part of this are you having trouble with? Can you show us the code you have tried so far?
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.