BookmarkSubscribeRSS Feed
santhosh
Fluorite | Level 6


i have a dataset

sno name m1 m2 s1 s2 e1 e1

1 A 20 30 25 45 26 27

1 B 25 32 55 20 41 25

1 C 27 40 28 44 46 37

1 D 29 50 35 42 36 42

i want output as

______________________________________________________________

|                   |          maths         |     Science             |     English             |

|SNo    name |  maths1| maths2  |science1 | science2  | english1|  english2|

|                    |           (1)           |           (2)                |         (3)                |

-------------------------------------------------------------------------------------------------------------

|1         A           20          30              25           45           26       27          |

|1         B           25          32             55           20           41        25          |

|1         C           27          40             28           44           46       37           |

|1         D           29          50             35           42           36          42        |

-------------------------------------------------------------------------------------------------------------

i want 1st level header as (1) (2) (3)

2nd level header as  maths1  maths2  |science1   science2  | english1   english2

3rd level headers as maths              Science                  English           

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Use a split char:

proc report split="~"...   /* Note the split=, you can put any character within the quotes */

     column ....;

     define sno / "SNo";

     define name / "Name";

     define m1/ "maths~maths1|maths2~(1)";   /* Note the tilde which indicates to line break */

     define m2 / "Science~science1|science2~(2)";

...

Jagadishkatam
Amethyst | Level 16

Please try

data have;

input

sno name $ m1 m2 s1 s2 e1 e1;

cards;

1 A 20 30 25 45 26 27

1 B 25 32 55 20 41 25

1 C 27 40 28 44 46 37

1 D 29 50 35 42 36 42

;

run;

ods rtf file='~\new.rtf';

proc report data = have nowindows headline headskip split='/' style(header)={just=c};

column ('Sno' sno) ('Name' name) ("Maths/Maths1|Maths2/(1)"  m1 m2 ) (  "science/science1|science2/(2)" s1 s2)  ( "english/english|english/(3)" e1 e2);

define sno / '';

define name / '';

define m1 / '';

define m2 / '';

define s1 / '';

define s2 / '';

define e1 / '';

define e2 / '';

run;

ods rtf close;

Thanks,

Jag

Thanks,
Jag
santhosh
Fluorite | Level 6

i want output as

______________________________________________________________

|                   |          maths         |     Science             |     English             |

|------------------------------------------------------------------------------------------------------------|

|SNo    name |  maths1| maths2  |science1 | science2  | english1|  english2 |

|------------------------------------------------------------------------------------------------------------|

|                   |           (1)            |           (2)                |         (3)                 |

|------------------------------------------------------------------------------------------------------------|

|1         A           20          30              25           45           26       27          |

|1         B           25          32             55           20           41        25          |

|1         C           27          40             28           44           46       37           |

|1         D           29          50             35           42           36          42        |

-------------------------------------------------------------------------------------------------------------

This is tablar format

1st heading above colunm will be (1) (2) (3)

above it seperate cels for Above M1 Maths1 and above M2 Maths2 so on

and above it maths science and englesh

i used | on to distingulish cells

RW9
Diamond | Level 26 RW9
Diamond | Level 26

As far as I am aware you cant have "across" labels, which is what the maths, science, and (1) (2), over *and* under other labels, only above column labels.  Then point being that information applies to all deceding column headers.  You could however fake it pretty easily:

data have;

input

sno name $ m1 m2 s1 s2 e1 e2;

cards;

1 A 20 30 25 45 26 27

1 B 25 32 55 20 41 25

1 C 27 40 28 44 46 37

1 D 29 50 35 42 36 42

;

run;

data inter (keep=sno name m s e);

  set have;

  length m s e $25;

  m=put(m1,2.)||right(put(m2,16.));

  s=put(s1,2.)||right(put(s2,16.));

  e=put(e1,2.)||right(put(e2,16.));

run;

ods pdf file="s:\temp\rob.pdf" style=statistical;

proc report data=inter split="~" nowd;

  column (' ' sno name) ('maths' m) ('science' s) ('english' e);

  define sno / "SNo" style(header)=[just=l];

  define name / "name" style(header)=[just=r];

  define m / "maths1|maths2~(1)" style(header)=[just=c];

  define s / "science1|science2~(2)" style(header)=[just=c];

  define e / "english1|english2~(3)" style(header)=[just=c];

run;

ods _all_ close;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 4 replies
  • 563 views
  • 0 likes
  • 3 in conversation