<?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 split cells in word report using SAS? in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-split-cells-in-word-report-using-SAS/m-p/931864#M26614</link>
    <description>&lt;P&gt;Have a look at the sample code below. The original target variable contents is split into two variables so that we can use the nesting of the across usage.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*
 * create dummy data
 */
data have;
  infile cards dlm=",";
  input
    week : date9.
    target : $32.
    value : 8.
  ;
  /*
   * split target into two variables
   */
  target2 = scan(target, 1, " ");
  strain = scan(target, 2, " ");
  format week date9.;
cards;
27May2024,Pox S1,19
27May2024,Pox S2,25
27May2024,Ebola A,4
27May2024,Ebola B,.
27May2024,Prion B,.
27May2024,Prion H,.
28May2024,Pox S1,10
28May2024,Pox S2,30
28May2024,Ebola A,4
28May2024,Ebola B,1
28May2024,Prion B,2
28May2024,Prion H,.
;

/*
 * create a format to print missing values
 * as requested
 */
proc format;
  value mynumber 
    . = "not detected"
    other = [8.]
  ;
run;

/*
 * proc report code
 * nocompletecols only print the actual values
 * group usage for week so that multiple rows are reduced to one
 * use of " " as label to suppress printing
 * target2 and strain used as across, the comma in the column
 * statement indicates the nesting
 */
proc report data=have nocompletecols;
  column ("week" week) target2, strain, value;
  define week / " " group;
  define target2 / " " across ;
  define strain / " " across;
  define value / " " analysis format=mynumber. center;
run;

/*
 * alternate way using proc tabulate
 */
proc tabulate data=have format=mynumber.;
class week target2 strain;
var value;

table week = " ", target2 = " " * strain = " " * value = " " * sum = " ";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 12 Jun 2024 06:39:09 GMT</pubDate>
    <dc:creator>BrunoMueller</dc:creator>
    <dc:date>2024-06-12T06:39:09Z</dc:date>
    <item>
      <title>How to split cells in word report using SAS?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-split-cells-in-word-report-using-SAS/m-p/931850#M26613</link>
      <description>&lt;P&gt;I have a two part question.&lt;/P&gt;&lt;P&gt;How would I create the table below using proc report? I can't figure out how to split the cells underneath the targets!&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="lu_king_1-1718156496567.png" style="width: 515px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/97241iB931ECC500F809E6/image-dimensions/515x151?v=v2" width="515" height="151" role="button" title="lu_king_1-1718156496567.png" alt="lu_king_1-1718156496567.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Second question: In my dataset I have one variable 'Target' containing both the target and the strain (Pox S1, Pox S2, etc.) would I still be able to create this table keeping it like that, or should I reshape my data set?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the help!&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2024 01:42:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-split-cells-in-word-report-using-SAS/m-p/931850#M26613</guid>
      <dc:creator>lu_king</dc:creator>
      <dc:date>2024-06-12T01:42:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to split cells in word report using SAS?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-split-cells-in-word-report-using-SAS/m-p/931864#M26614</link>
      <description>&lt;P&gt;Have a look at the sample code below. The original target variable contents is split into two variables so that we can use the nesting of the across usage.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*
 * create dummy data
 */
data have;
  infile cards dlm=",";
  input
    week : date9.
    target : $32.
    value : 8.
  ;
  /*
   * split target into two variables
   */
  target2 = scan(target, 1, " ");
  strain = scan(target, 2, " ");
  format week date9.;
cards;
27May2024,Pox S1,19
27May2024,Pox S2,25
27May2024,Ebola A,4
27May2024,Ebola B,.
27May2024,Prion B,.
27May2024,Prion H,.
28May2024,Pox S1,10
28May2024,Pox S2,30
28May2024,Ebola A,4
28May2024,Ebola B,1
28May2024,Prion B,2
28May2024,Prion H,.
;

/*
 * create a format to print missing values
 * as requested
 */
proc format;
  value mynumber 
    . = "not detected"
    other = [8.]
  ;
run;

/*
 * proc report code
 * nocompletecols only print the actual values
 * group usage for week so that multiple rows are reduced to one
 * use of " " as label to suppress printing
 * target2 and strain used as across, the comma in the column
 * statement indicates the nesting
 */
proc report data=have nocompletecols;
  column ("week" week) target2, strain, value;
  define week / " " group;
  define target2 / " " across ;
  define strain / " " across;
  define value / " " analysis format=mynumber. center;
run;

/*
 * alternate way using proc tabulate
 */
proc tabulate data=have format=mynumber.;
class week target2 strain;
var value;

table week = " ", target2 = " " * strain = " " * value = " " * sum = " ";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Jun 2024 06:39:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-split-cells-in-word-report-using-SAS/m-p/931864#M26614</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2024-06-12T06:39:09Z</dc:date>
    </item>
  </channel>
</rss>

