BookmarkSubscribeRSS Feed
subh
Calcite | Level 5

Hi,

I have  one sas input table with three column(x y and z).(example below)

X          Y           Z 

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

11     market     22

33     market     44

55     market     77

I need to display like below(In a single coumn REPORT) by proc report in ods rtf

REPORT

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

11

market    

22

33

market    

44

55

market    

77



Please help me how to do the sas code for this.


Thank You.

2 REPLIES 2
ballardw
Super User

I'm not sure if Proc Report will let you do something like that without lots of headaches.

But this may help:

data _null_;

     file print;

     set have;

     if _n_= 1 then put "Report";  /* I'm skipping the underline as there's enough system dependencies

I don't want to add complexity at this point*/

     put x;

     put y;

     put z;

end;

Cynthia_sas
SAS Super FREQ

Hi: First of all, the SAS/GRAPH forum is not the correct place to post a PROC REPORT question. But neither PROC PRINT nor PROC REPORT would produce a report like this without restructuring the data. If the OP wants an RTF output file, then they might consider using either a program like yours or something like this for a report.

Cynthia

** Method 1 Use File PRINT ODS;

ods rtf file="c:\temp\restructure_data_null.rtf";

data _null_;

title '1) Use DATA step';

length repcol $50;

set sashelp.class(keep=name sex height);

file print ods=(variables=(repcol));

  repcol = '~~~~~~~~~~';

  put _ods_;

  repcol = name;

  put _ods_;

  repcol = sex;

  put _ods_;

  repcol = put(height,4.1);

  put _ods_;

run;

ods rtf close;

** Method 2 Use PROC REPORT;

data restruct;

  length repcol $50;

  set sashelp.class(keep=name sex height);

  varord = 0;

  repord = _n_;

  varord +1;

  repcol = name;

  output;

  varord+1;

  repcol = sex;

  output;

  varord + 1;

  repcol = put(height,4.1);

  output;

run;

ods rtf file="c:\temp\restruct_report.rtf";

proc report data=restruct nowd;

  title '2) Use PROC REPORT with restructured data';

  column repord varord repcol;

  define repord /order noprint;

  define varord / order noprint;

  define repcol/ display;

  compute before repord / style=Header;

    line '~~~~~~~~~~';

  endcomp;

  run;

  ods rtf close;

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 758 views
  • 0 likes
  • 3 in conversation