Hello everyone, i hope you are doing well!
i have the table bellow :
data have; input sales $ client $ Monday Tuesday Wednesday Thursday Friday ; datalines; sale1 A 1 . . . . sale2 B . 0 . . . sale3 C . . 2 . . sale3 C . . . 1 . sale4 D 0 . . . . sale4 D . 2 . . . sale4 D . . 1 . . sale4 D . . . 0 . ; run;
i have some records that get duplicated due to different day, like sale3 and sale4 ...
i want a table that combine the same sale in one line where i can see each day's number of sales,
it's something like :
sales | client | Monday | Tuesday | Wednesday | Thursday | Friday |
sale1 | A | 1 | . | . | . | . |
sale2 | B | . | 0 | . | . | . |
sale3 | C | . | . | 2 | 1 | . |
sale4 | D | 0 | 2 | 1 | 0 | . |
i hope you could help ! Thank you
proc summary data=have nway;
class sales client;
var monday tuesday wednesday thursday friday;
output out=want sum=;
run;
Suggestion: it is usually a bad idea to have calendar information in a variable name. Your subsequent programming becomes much easier when you create a long data set, where you have one record for each value of sales, client and date, and then one variable. You can change this via PROC TRANSPOSE or other methods.
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!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: