BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Ronein
Meteorite | Level 14

Hello

What is the way to create such report when for each day there is freq report by 3 fields: X1,X2,X3.

For each day we need to see the fields names and categories names and need to have a black column as a gap between days.

Ronein_2-1613197709321.png

 

 

Data rawtbl;
input ID date : date9. x1 $ x2  $ x3 $ ;
cards;
1 01jan2021 a a b
2 01jan2021 b c b
3 01jan2021 c a b
4 01jan2021 a c c
5 02an2021 b b b
6 02an2021 a c b
7 03jan2021 c a b
8 03jan2021 a b b
9 03jan2021 a a c
;
run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Shmuel
Garnet | Level 18

Check next code:

Data rawtbl;
input ID date : date9. x1 $ x2  $ x3 $ ;
format date ddmmyy10.;
cards;
1 01jan2021 a a b
2 01jan2021 b c b
3 01jan2021 c a b
4 01jan2021 a c c
5 02jan2021 b b b
6 02jan2021 a c b
7 03jan2021 c a b
8 03jan2021 a b b
9 03jan2021 a a c
;
run;

proc format lib=work;
  value $catg
   'a' = 'x_a'
   'b' = 'x_b'
   'c' = 'x_c'
; run;
data to_rep;
 set rawtbl;
     length category $3;
     category = put(x1,$catg.); field='x1'; freq=1; output;
     category = put(x2,$catg.); field='x2'; freq=1; output;
     category = put(x3,$catg.); field='x3'; freq=1; output;
     drop x1 - x3;
run;
proc tabulate data=to_rep;
  class date field category;
  var freq;
  table field*category,
        date*freq*sum=' ';
run;

View solution in original post

1 REPLY 1
Shmuel
Garnet | Level 18

Check next code:

Data rawtbl;
input ID date : date9. x1 $ x2  $ x3 $ ;
format date ddmmyy10.;
cards;
1 01jan2021 a a b
2 01jan2021 b c b
3 01jan2021 c a b
4 01jan2021 a c c
5 02jan2021 b b b
6 02jan2021 a c b
7 03jan2021 c a b
8 03jan2021 a b b
9 03jan2021 a a c
;
run;

proc format lib=work;
  value $catg
   'a' = 'x_a'
   'b' = 'x_b'
   'c' = 'x_c'
; run;
data to_rep;
 set rawtbl;
     length category $3;
     category = put(x1,$catg.); field='x1'; freq=1; output;
     category = put(x2,$catg.); field='x2'; freq=1; output;
     category = put(x3,$catg.); field='x3'; freq=1; output;
     drop x1 - x3;
run;
proc tabulate data=to_rep;
  class date field category;
  var freq;
  table field*category,
        date*freq*sum=' ';
run;

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
  • 449 views
  • 1 like
  • 2 in conversation