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-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 516 views
  • 1 like
  • 2 in conversation