BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
NewUsrStat
Pyrite | Level 9

Hi guys, 

suppose to have the following table: 

  N                   Count           Figure

100                   28                 Psicol

  0                     12                  Psicol 

50                     6                   Psicol

20                     2                   Psicol

80                     2                   Psicol

60                     1                    Psicol

0                       29                 Psy

100                   10                 Psy

50                     5                   Psy

20                     3                   Psy

80                     2                   Psy

10                      1                    Psy

70                     1                    Psy                        

 

Is there a way to format the table in this way? 

 

Figure           0          10            20        30         40         50        60       70          80        90         100

Psicol           12         na             2         na          na           6           1          na           2          na          28

Psy                29         1              3          na         na            5           na        1             2          na          10             

 

Thank you in advance     

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Please, @NewUsrStat from now on, provide data as working SAS data step code, as shown below.

 

data have;
input N Count Figure $;
cards;
100                   28                 Psicol
  0                     12                  Psicol 
50                     6                   Psicol
20                     2                   Psicol
80                     2                   Psicol
60                     1                    Psicol
0                       29                 Psy
100                   10                 Psy
50                     5                   Psy
20                     3                   Psy
80                     2                   Psy
10                      1                    Psy
70                     1                    Psy  
;

proc report data=have;
    columns figure count,n;
    define figure/group "Figure";
    define n/across order=internal ' ';
    define count/sum " ";
run;
--
Paige Miller

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

Please, @NewUsrStat from now on, provide data as working SAS data step code, as shown below.

 

data have;
input N Count Figure $;
cards;
100                   28                 Psicol
  0                     12                  Psicol 
50                     6                   Psicol
20                     2                   Psicol
80                     2                   Psicol
60                     1                    Psicol
0                       29                 Psy
100                   10                 Psy
50                     5                   Psy
20                     3                   Psy
80                     2                   Psy
10                      1                    Psy
70                     1                    Psy  
;

proc report data=have;
    columns figure count,n;
    define figure/group "Figure";
    define n/across order=internal ' ';
    define count/sum " ";
run;
--
Paige Miller
NewUsrStat
Pyrite | Level 9
Thank you very much and sorry for the input data.
data_null__
Jade | Level 19

This is one way to create variables for missing N 30, 40, 90.

 

 

data have;
   input N count figure $;
   cards;
100                   28                 Psicol
  0                     12                  Psicol 
50                     6                   Psicol
20                     2                   Psicol
80                     2                   Psicol
60                     1                    Psicol
0                       29                 Psy
100                   10                 Psy
50                     5                   Psy
20                     3                   Psy
80                     2                   Psy
10                      1                    Psy
70                     1                    Psy                        
;;;;
   run;

data frame;
   do N = 0 to 100 by 10;
      output;
      end;
   run;
data have2;
   set frame have;
   run;
proc print;
   run;
proc transpose data=have2 
      out=want(where=(not missing(figure)) drop=_name_) 
      prefix=N_;
   by figure;
   var count;
   id N;
   run;
proc print;
   run;


Capture.PNGCapture2.PNG

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 690 views
  • 1 like
  • 3 in conversation