<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: how to control the indent in listing output in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-control-the-indent-in-listing-output/m-p/730896#M227656</link>
    <description>Thanks. I also tried compute block and used call define to set style. This did not work on listing output.</description>
    <pubDate>Fri, 02 Apr 2021 01:11:35 GMT</pubDate>
    <dc:creator>Niugg2010</dc:creator>
    <dc:date>2021-04-02T01:11:35Z</dc:date>
    <item>
      <title>how to control the indent in listing output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-control-the-indent-in-listing-output/m-p/730847#M227633</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I want to get listing output_1(shown below, the subcat lines should be indented). However when I ran my below code I got output_2 (shown below). I tried to use 'style' to control the output, and 'style' worked for rtf output, but not for listing output. Can someone help me out about how to control indent for listing output? Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;output_1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; output_2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="fig_1.JPG" style="width: 388px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/56822i9EC99C94ED3F89C6/image-dimensions/388x101?v=v2" width="388" height="101" role="button" title="fig_1.JPG" alt="fig_1.JPG" /&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="fig_2.JPG" style="width: 353px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/56821i26404E14BCC1996E/image-dimensions/353x93?v=v2" width="353" height="93" role="button" title="fig_2.JPG" alt="fig_2.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x;
	format x $100.;
	x='cat_A';
	output;
	x=repeat("Subcat ", 30);
	output;
run;
ods listing file="xxx\try_1.lst";
proc report data=x;
	column  x;
	define x / 'HEADER' width=50 flow;
run;
ods listing close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Apr 2021 20:33:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-control-the-indent-in-listing-output/m-p/730847#M227633</guid>
      <dc:creator>Niugg2010</dc:creator>
      <dc:date>2021-04-01T20:33:50Z</dc:date>
    </item>
    <item>
      <title>Re: how to control the indent in listing output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-control-the-indent-in-listing-output/m-p/730893#M227654</link>
      <description>&lt;P&gt;That really looks like you want the long text to be a different variable. ANY property applied to the long text will be the same for the Cat_A unless you do something by parsing the values in a COMPUTE block, and I'm not sure what that compute block would look like.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Apr 2021 00:40:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-control-the-indent-in-listing-output/m-p/730893#M227654</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-04-02T00:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: how to control the indent in listing output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-control-the-indent-in-listing-output/m-p/730896#M227656</link>
      <description>Thanks. I also tried compute block and used call define to set style. This did not work on listing output.</description>
      <pubDate>Fri, 02 Apr 2021 01:11:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-control-the-indent-in-listing-output/m-p/730896#M227656</guid>
      <dc:creator>Niugg2010</dc:creator>
      <dc:date>2021-04-02T01:11:35Z</dc:date>
    </item>
    <item>
      <title>Re: how to control the indent in listing output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-control-the-indent-in-listing-output/m-p/730906#M227660</link>
      <description>&lt;P&gt;To indent the value just add spaces in the front of the value.&lt;/P&gt;
&lt;P&gt;If you want the flowed lines to also indent then you probably need to wrap the text yourself.&lt;/P&gt;
&lt;P&gt;Example :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x;
	length x $100;
	x='cat_A';
	output;
  x=substr('  ' || repeat('lorum ipsum ',4),1,50);
	output;
  x=substr('  ' || repeat('lorum ipsum ',4),1,50);
	output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;  HEADER
  cat_A
    lorum ipsum lorum ipsum lorum ipsum lorum ipsum
    lorum ipsum lorum ipsum lorum ipsum lorum ipsum
&lt;/PRE&gt;
&lt;P&gt;PS Why did you attach the $100. format specification to the variable X?&amp;nbsp; If you want to define a variable use the LENGTH statement or the LENGTH= attribute of the ATTRIB statement.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Apr 2021 03:23:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-control-the-indent-in-listing-output/m-p/730906#M227660</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-02T03:23:27Z</dc:date>
    </item>
    <item>
      <title>Re: how to control the indent in listing output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-control-the-indent-in-listing-output/m-p/730963#M227677</link>
      <description>&lt;P&gt;Thanks for your suggestion. Adding spaces is what I used in my report.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, if the 'subcat ' text is very long and show in multiple lines, only the first line is indented, which makes the report difficult to read. In your output, if you set the width is small (eg. width=30 in define) in your proc report, you will find the issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Apr 2021 12:35:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-control-the-indent-in-listing-output/m-p/730963#M227677</guid>
      <dc:creator>Niugg2010</dc:creator>
      <dc:date>2021-04-02T12:35:26Z</dc:date>
    </item>
    <item>
      <title>Re: how to control the indent in listing output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-control-the-indent-in-listing-output/m-p/730965#M227679</link>
      <description>&lt;P&gt;Like I said.&amp;nbsp; Write your own wrapping logic.&lt;/P&gt;
&lt;P&gt;Here is such a program from years ago.&amp;nbsp; You would need to post-process the output of this to prepend the leading spaces for the indentation.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro wrap
/*------------------------------------------------------------------------------
Wrap long string into mulitple observations
------------------------------------------------------------------------------*/
(dsnin=    /* Input dataset */
,dsnout=   /* Output dataset */
,invar=    /* Variable to wrap */
,outvar=   /* Name of wrapped variable */
,len=80    /* Length to wrap */
,split='0d'x /* Character(s) to use for forcing new observation */
,break=",- " /* Character(s) used to break long words across lines */
);
/*------------------------------------------------------------------------------
Wrap a long variable into multiple lines. Split characters will cause
the starting of a new line.  Break characters will control where words can be
broken to fit into a line.
------------------------------------------------------------------------------*/
%local macro parmerr varlen vartype;
%let macro=WRAP;

%parmv(dsnin,_req=1)
%parmv(dsnout,_req=1)
%parmv(invar,_req=1)
%parmv(outvar,_req=1)
%parmv(len,_val=positive,_req=1)
%let varlen=%varexist(&amp;amp;dsnin,&amp;amp;outvar,len);
%let vartype=%varexist(&amp;amp;dsnin,&amp;amp;outvar,type);
%if (&amp;amp;vartype = C) %then %do;
  %if (&amp;amp;varlen and (&amp;amp;varlen &amp;lt; &amp;amp;len) ) %then
    %parmv(len,_msg=&amp;amp;outvar already is defined in &amp;amp;dsnin as length &amp;amp;varlen)
  ;
%end;
%else %do;
  %parmv(outvar,_msg=&amp;amp;outvar is defined in &amp;amp;dsnin as numeric)
  %let vartype=%str(numeric );
%end;

%if (&amp;amp;parmerr) %then %goto quit;

*------------------------------------------------------------------------------;
* Wrap variable into multiple observations ;
*------------------------------------------------------------------------------;
data &amp;amp;dsnout;
  &amp;amp;outvar = repeat(' ',&amp;amp;len-1);
  set &amp;amp;dsnin;
  drop _save _pnum _done _split _para _lnum;
  _save=&amp;amp;invar;
  _pnum=0;
  _done=0;
  do until (_done);
    _pnum+1;
%if %length(&amp;amp;split) %then %do;
    _split = indexc(_save,&amp;amp;split);
%end;
%else %do;
    _split=0;
%end;
    if (_split &amp;gt; 1) then do;
      _para = substr(_save,1,_split-1);
      _save = substr(_save,_split+1);
    end;
    else if (_split = 1) then do;
      _para = ' ';
      _save = substr(_save,2);
    end;
    else do;
      _para = _save;
      _done=1;
    end;
    _lnum=1;
    do while (length(_para) &amp;gt; &amp;amp;len);
      &amp;amp;outvar = substr(_para,1,&amp;amp;len);
      _split =indexc(&amp;amp;outvar,&amp;amp;break);
      * ? Need to move a broken word from current line to next line ? ;
      if length(compress(substr(_para,&amp;amp;len,2))) = 2 and (_split &amp;gt; 0) then do;
        _split = indexc( reverse(trim(&amp;amp;outvar)) ,&amp;amp;break);
        &amp;amp;outvar = substr(&amp;amp;outvar,1,&amp;amp;len - _split + 1);
      end;
      output;
      _lnum+1;
      _para = left(substr(_para,length(&amp;amp;outvar)+1));
    end;
    if (_lnum=1) or (_para ne ' ') then do;
      &amp;amp;outvar = _para;
      output;
    end;
  end;

run;

%quit:
%mend wrap;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Apr 2021 12:44:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-control-the-indent-in-listing-output/m-p/730965#M227679</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-02T12:44:58Z</dc:date>
    </item>
    <item>
      <title>Re: how to control the indent in listing output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-control-the-indent-in-listing-output/m-p/730970#M227681</link>
      <description>&lt;P&gt;To get PROC REPORT to insert group heading lines use COMPUTE blocks.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x;
  length group $50 x $100;
  group='cat_A';
  x = repeat('lorum ipsum ',20);
  space='   ';
run;
proc report data=x;
  column  space group x;
  define space / width=2 spacing=0 ' ' ;
  define group / group noprint;
  compute before group;
     line @1 group $50. ;
  endcomp;
  define x / 'HEADER'  width=50 flow;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;    HEADER
cat_A
    lorum ipsum lorum ipsum lorum ipsum lorum ipsum
    lorum ipsum lorum ipsum lorum ipsum lorum ipsum
    loru

&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Apr 2021 12:57:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-control-the-indent-in-listing-output/m-p/730970#M227681</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-02T12:57:33Z</dc:date>
    </item>
    <item>
      <title>Re: how to control the indent in listing output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-control-the-indent-in-listing-output/m-p/730979#M227684</link>
      <description>&lt;P&gt;Thanks a lot.&lt;/P&gt;
&lt;P&gt;That is interesting. I should gave a more closer example.&lt;/P&gt;
&lt;P&gt;Please see below example. This example only have 2 groups (group 1 and 2), but actually we have more groups, so the "System Organ Class ...." column can not be wider.&amp;nbsp; The Yellow marked part is SOC, and gray marked part is PT. The blue circled items have two rows due to the column width is not enough, and I want the two rows indented, not only the first row, so that the output should look better. If output is rft, it is easy to do. But if output is listing, I have not figured out a good method.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="f1.JPG" style="width: 555px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/56845iC1C638E3C8DF6CE5/image-dimensions/555x472?v=v2" width="555" height="472" role="button" title="f1.JPG" alt="f1.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Apr 2021 13:45:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-control-the-indent-in-listing-output/m-p/730979#M227684</guid>
      <dc:creator>Niugg2010</dc:creator>
      <dc:date>2021-04-02T13:45:41Z</dc:date>
    </item>
    <item>
      <title>Re: how to control the indent in listing output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-control-the-indent-in-listing-output/m-p/730982#M227685</link>
      <description>This macro is very interesting. I guess it should work for my case.</description>
      <pubDate>Fri, 02 Apr 2021 13:56:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-control-the-indent-in-listing-output/m-p/730982#M227685</guid>
      <dc:creator>Niugg2010</dc:creator>
      <dc:date>2021-04-02T13:56:19Z</dc:date>
    </item>
    <item>
      <title>Re: how to control the indent in listing output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-control-the-indent-in-listing-output/m-p/730983#M227686</link>
      <description>Can you give me some examples to use this macro?</description>
      <pubDate>Fri, 02 Apr 2021 14:16:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-control-the-indent-in-listing-output/m-p/730983#M227686</guid>
      <dc:creator>Niugg2010</dc:creator>
      <dc:date>2021-04-02T14:16:42Z</dc:date>
    </item>
    <item>
      <title>Re: how to control the indent in listing output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-control-the-indent-in-listing-output/m-p/730984#M227687</link>
      <description>I an trying to use your macro, and it has errors.  I guess I missed %parmv and %varexist macros.</description>
      <pubDate>Fri, 02 Apr 2021 14:32:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-control-the-indent-in-listing-output/m-p/730984#M227687</guid>
      <dc:creator>Niugg2010</dc:creator>
      <dc:date>2021-04-02T14:32:36Z</dc:date>
    </item>
    <item>
      <title>Re: how to control the indent in listing output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-control-the-indent-in-listing-output/m-p/730986#M227688</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/100692"&gt;@Niugg2010&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I an trying to use your macro, and it has errors. I guess I missed %parmv and %varexist macros.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You should be able to comment out the parameter validation section of the macro.&amp;nbsp; Or you could get those macros from &lt;A href="https://github.com/sasutils/macros" target="_self"&gt;GITHUB&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test1;
 length invar $ 4000 outvar $40;
 input invar $80.;
*---+----10---+----20---+----30---+----40---+----50 ;
cards;
This is a line that is long, and should wrap
This is two paragraphs./This is a line that is long-And should wrap
This is two splits in a row.//How does it work?
This hyphen is right at the b-oundary.
Try it when a word ends right. On the boundry.
Check if a word_is_longer_than_a_single_line. What will it do?
/First character is split.
Last character is split./

run;
options mprint;
%wrap
(dsnin=test1
,dsnout=test2
,invar=invar
,outvar=outvar
,len=30
,split="/"
);

proc print;
 var outvar invar;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Apr 2021 14:38:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-control-the-indent-in-listing-output/m-p/730986#M227688</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-02T14:38:54Z</dc:date>
    </item>
    <item>
      <title>Re: how to control the indent in listing output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-control-the-indent-in-listing-output/m-p/730996#M227689</link>
      <description>Tom, Thank you very much.</description>
      <pubDate>Fri, 02 Apr 2021 16:34:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-control-the-indent-in-listing-output/m-p/730996#M227689</guid>
      <dc:creator>Niugg2010</dc:creator>
      <dc:date>2021-04-02T16:34:41Z</dc:date>
    </item>
  </channel>
</rss>

