BookmarkSubscribeRSS Feed
SASlearner97
Obsidian | Level 7

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

1 REPLY 1
PaigeMiller
Diamond | Level 26
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.

--
Paige Miller

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 287 views
  • 0 likes
  • 2 in conversation