<?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 calculate number of subject when several treatment periods are available in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-number-of-subject-when-several-treatment/m-p/332948#M74986</link>
    <description>&lt;P&gt;Your only macro-related statement is in&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set tnstfd11;
call symputx(trt,ns);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which uses a dataset you have not provided any information for.&lt;/P&gt;</description>
    <pubDate>Wed, 15 Feb 2017 11:15:47 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2017-02-15T11:15:47Z</dc:date>
    <item>
      <title>How to calculate number of subject when several treatment periods are available</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-number-of-subject-when-several-treatment/m-p/332903#M74975</link>
      <description>&lt;P&gt;Dear,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using following code to create macro variables for data one. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But my actual data contains three treatments (trt1,trt2,trt3) and I am repeating the code three times to calculate macro variables. Is there any other solution to simplify code for data two; The placebo values should not included in Total.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data one;&lt;BR /&gt;input id trt1 $;&lt;BR /&gt;datalines;&lt;BR /&gt;1 10&lt;BR /&gt;2 10&lt;BR /&gt;3 20&lt;BR /&gt;4 30&lt;BR /&gt;5 20&lt;BR /&gt;6 30&lt;BR /&gt;7 30&lt;BR /&gt;;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table NS as&lt;BR /&gt;select count(distinct id) as NS,trt1&lt;BR /&gt;from one&lt;BR /&gt;group by trt1;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data ns1;&lt;BR /&gt;set ns;&lt;BR /&gt;trt1=strip(trt1);&lt;BR /&gt;if trt1='10' then trt='A';&lt;BR /&gt;if trt1='20' then trt='B';&lt;BR /&gt;if trt1='30' then trt='C';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data ns2;&lt;BR /&gt;set ns1 end=done;&lt;BR /&gt;Total + ns;&lt;BR /&gt;output;&lt;BR /&gt;if done;&lt;BR /&gt;ns = TOTAL;&lt;BR /&gt;trt='D';&lt;BR /&gt;trt1='Total';&lt;BR /&gt;output;&lt;BR /&gt;drop Total;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data _null_;&lt;BR /&gt;set tnstfd11;&lt;BR /&gt;call symputx(trt,ns);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;data two;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;input id trt1 $; trt2 $ trt3 $&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;datalines;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1 10 20 30&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2 10 30 20&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3 20 10 place&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4 30 10 place&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;5 20 30 place&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;6 30 20 place&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;7 30 20 place&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;8 10 30 20&lt;/P&gt;&lt;P&gt;;&lt;BR /&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2017 05:02:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-number-of-subject-when-several-treatment/m-p/332903#M74975</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2017-02-15T05:02:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate number of subject when several treatment periods are available</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-number-of-subject-when-several-treatment/m-p/332915#M74979</link>
      <description>&lt;P&gt;How about next code:&lt;/P&gt;
&lt;PRE&gt;data one;&lt;BR /&gt;input id trt1 $;&lt;BR /&gt;datalines;&lt;BR /&gt;1 10&lt;BR /&gt;2 10&lt;BR /&gt;3 20&lt;BR /&gt;4 30&lt;BR /&gt;5 20&lt;BR /&gt;6 30&lt;BR /&gt;7 30&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;proc format;&lt;BR /&gt; value $trtx&lt;BR /&gt; '10' = 'A'&lt;BR /&gt; '20' = 'B'&lt;BR /&gt; '30' = 'C'&lt;BR /&gt; ; run;&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table NS as&lt;BR /&gt;select count(distinct id) as NS,&lt;BR /&gt; strip(trt1) as trt1,&lt;BR /&gt; put(trt1,$trtx.) as trt&lt;BR /&gt;from one&lt;BR /&gt;group by trt1;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;data ns2;&lt;BR /&gt; set ns end=done;&lt;BR /&gt;Total + ns;&lt;BR /&gt;output;&lt;BR /&gt;if done;&lt;BR /&gt;ns = TOTAL;&lt;BR /&gt;trt='D';&lt;BR /&gt;trt1='Total';&lt;BR /&gt;output;&lt;BR /&gt;drop Total;&lt;BR /&gt;run;&lt;BR /&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In case you have more values to convert - add those values to the format TRTX.&lt;/P&gt;
&lt;P&gt;Having trt2, trt3 - add similar lines as trt1 to the sql step.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2017 07:16:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-number-of-subject-when-several-treatment/m-p/332915#M74979</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-02-15T07:16:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate number of subject when several treatment periods are available</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-number-of-subject-when-several-treatment/m-p/332918#M74980</link>
      <description>&lt;P&gt;Having trt2, trt3 etc. - pay attemtion to next code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
  value $trtx
   '10' = 'A'
   '20' = 'B'
   '30' = 'C'
   other = '*'  /* ???? */
 ; run;

proc sql;
create table NS as
select count(distinct id) as NS,
       strip(trt1) as trt1,
       put(trt1,$trtx.) as trt_1,
       
       strip(trt2) as trt2,
       put(trt2,$trtx.) as trt_2,       

       strip(trt3) as trt3,
       put(trt3,$trtx.) as trt_3      
from one
group by trt1;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;in proc &lt;STRONG&gt;format&lt;/STRONG&gt; - see &lt;STRONG&gt;other=&lt;/STRONG&gt; row for missing predefined values/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I could not understand what macro variables you want to create.&lt;/P&gt;
&lt;P&gt;trt is a result of trt1. How to you want to deal with trt2, trt3 ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your code contains:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;data _null_;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;set &lt;STRONG&gt;tnstfd11&lt;/STRONG&gt;; &amp;nbsp; /* where from is this dataset ??? */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;call symputx(trt,ns);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2017 07:54:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-number-of-subject-when-several-treatment/m-p/332918#M74980</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-02-15T07:54:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate number of subject when several treatment periods are available</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-number-of-subject-when-several-treatment/m-p/332948#M74986</link>
      <description>&lt;P&gt;Your only macro-related statement is in&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set tnstfd11;
call symputx(trt,ns);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which uses a dataset you have not provided any information for.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2017 11:15:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-number-of-subject-when-several-treatment/m-p/332948#M74986</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-02-15T11:15:47Z</dc:date>
    </item>
  </channel>
</rss>

