<?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: i want a calculated values of number of subjects in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/i-want-a-calculated-values-of-number-of-subjects/m-p/238054#M43700</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am sorry. I may be confusing you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need&amp;nbsp;&lt;SPAN&gt; Subjects whose values are in&amp;nbsp;negative(ex: -1.334) at visit 3, but positive(ex: 1.23) during treatment and &amp;nbsp;Subjects tested positive(ex: positive values at least once) at least once during treatment period&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 07 Dec 2015 13:04:00 GMT</pubDate>
    <dc:creator>vraj1</dc:creator>
    <dc:date>2015-12-07T13:04:00Z</dc:date>
    <item>
      <title>i want a calculated values of number of subjects</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-want-a-calculated-values-of-number-of-subjects/m-p/238044#M43692</link>
      <description>&lt;P&gt;I have a dataset which has values from negative and positive.&lt;/P&gt;
&lt;P&gt;ex:&lt;/P&gt;
&lt;P&gt;subj &amp;nbsp; value &amp;nbsp;visit &amp;nbsp; &amp;nbsp;trt&lt;/P&gt;
&lt;P&gt;101 &amp;nbsp; &amp;nbsp;-1.3 &amp;nbsp; &amp;nbsp; &amp;nbsp;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; A&lt;/P&gt;
&lt;P&gt;102 &amp;nbsp; &amp;nbsp;2.1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; A&lt;/P&gt;
&lt;P&gt;103 &amp;nbsp; &amp;nbsp;-1.2 &amp;nbsp; &amp;nbsp; &amp;nbsp;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; B&lt;/P&gt;
&lt;P&gt;101 &amp;nbsp; &amp;nbsp; 3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4 &amp;nbsp; &amp;nbsp; &amp;nbsp;A&lt;/P&gt;
&lt;P&gt;102 &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;B&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to have number of subjects and percentage who have negative(value) as visit 3 and positive value after visit3. Also another count and percentage of subjects who are postive atleast ones .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anyone help me&lt;/P&gt;</description>
      <pubDate>Mon, 07 Dec 2015 11:52:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-want-a-calculated-values-of-number-of-subjects/m-p/238044#M43692</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2015-12-07T11:52:17Z</dc:date>
    </item>
    <item>
      <title>Re: i want a calculated values of number of subjects</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-want-a-calculated-values-of-number-of-subjects/m-p/238046#M43693</link>
      <description>&lt;P&gt;Give sample of your desired output..&lt;/P&gt;</description>
      <pubDate>Mon, 07 Dec 2015 12:01:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-want-a-calculated-values-of-number-of-subjects/m-p/238046#M43693</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2015-12-07T12:01:18Z</dc:date>
    </item>
    <item>
      <title>Re: i want a calculated values of number of subjects</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-want-a-calculated-values-of-number-of-subjects/m-p/238047#M43694</link>
      <description>I need N (%) for Subjects tested negative at visit 3, but positive during treatment and N (%) Subjects tested positive at least once during treatment period</description>
      <pubDate>Mon, 07 Dec 2015 12:05:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-want-a-calculated-values-of-number-of-subjects/m-p/238047#M43694</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2015-12-07T12:05:40Z</dc:date>
    </item>
    <item>
      <title>Re: i want a calculated values of number of subjects</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-want-a-calculated-values-of-number-of-subjects/m-p/238053#M43699</link>
      <description>&lt;P&gt;Here's the code to count the number of times this happens, I figure you can turn that into a percentage&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;UNTESTED CODE&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have;
    by subj visit;
run;

data count;
    set have;
    prev_value=lag(value);
    if visit=4 and prev_value&amp;lt;0 and value&amp;gt;0 then output;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Dec 2015 12:51:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-want-a-calculated-values-of-number-of-subjects/m-p/238053#M43699</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2015-12-07T12:51:09Z</dc:date>
    </item>
    <item>
      <title>Re: i want a calculated values of number of subjects</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-want-a-calculated-values-of-number-of-subjects/m-p/238054#M43700</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am sorry. I may be confusing you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need&amp;nbsp;&lt;SPAN&gt; Subjects whose values are in&amp;nbsp;negative(ex: -1.334) at visit 3, but positive(ex: 1.23) during treatment and &amp;nbsp;Subjects tested positive(ex: positive values at least once) at least once during treatment period&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Dec 2015 13:04:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-want-a-calculated-values-of-number-of-subjects/m-p/238054#M43700</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2015-12-07T13:04:00Z</dc:date>
    </item>
    <item>
      <title>Re: i want a calculated values of number of subjects</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-want-a-calculated-values-of-number-of-subjects/m-p/238055#M43701</link>
      <description>&lt;P&gt;Something like this should suffice:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table WANT as
  select  count(distinct COALESCE(A.SUBJ,B.SUBJ)) as SUBJ_COUNT,
          (select count(distinct SUBJ) deom HAVE) as TOTAL_SUBJ,
          CALCULATED SUBJ_COUNT / CALCULATED TOTAL_SUBJ * 100 as PCENT
  from    (select * from HAVE where VISIT=3) A
  full join (select * from HAVE where VISIT=4) B
  on      A.SUBJ=B.SUBJ
  where   A.VALUE &amp;lt; 0 and B.VALUE &amp;gt; 0;
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Dec 2015 13:24:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-want-a-calculated-values-of-number-of-subjects/m-p/238055#M43701</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-12-07T13:24:04Z</dc:date>
    </item>
    <item>
      <title>Re: i want a calculated values of number of subjects</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-want-a-calculated-values-of-number-of-subjects/m-p/238225#M43746</link>
      <description>&lt;P&gt;m sorry as i am new to sas i am still finding it difficult.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;what will the above program do and what does deom mean?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want 2 counts&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1)Subjects tested positive at least once during treatment period &amp;nbsp; - N(%)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2)&amp;nbsp;Subjects tested negative &amp;nbsp;at visit 3, but positive during treatment - N(%)&lt;/P&gt;</description>
      <pubDate>Tue, 08 Dec 2015 08:29:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-want-a-calculated-values-of-number-of-subjects/m-p/238225#M43746</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2015-12-08T08:29:23Z</dc:date>
    </item>
    <item>
      <title>Re: i want a calculated values of number of subjects</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-want-a-calculated-values-of-number-of-subjects/m-p/238231#M43749</link>
      <description>&lt;P&gt;Ah, ok so you are just learning SAS. &amp;nbsp;Might I suggest you go through the help videos, and documentation and start off with the underlying language. &amp;nbsp;It looks like you are trying to program some clicnical output, there are a number of things to consider. &amp;nbsp;If your doing this for leraning, then best to understand the language first. &amp;nbsp;If you doing it for work, then you need to ask collegues as its likely they already have macro libraries, set programs, or examples that you can directly use.&lt;/P&gt;
&lt;P&gt;At a basic level you need to do three things:&lt;/P&gt;
&lt;P&gt;1) &amp;nbsp;Get big N, i.e. the number of distinct subjects in the dataset. &amp;nbsp;You can do this in a number of ways, proc freq/means etc. &amp;nbsp;I tend to use SQL for this:&lt;/P&gt;
&lt;PRE&gt;proc sql;
   create table N as
   select count(distinct SUBJ) as N
   from   HAVE;
quit;&lt;/PRE&gt;
&lt;P&gt;So (and I am trying to keep this basic, all this can be compressed and coded differently, but it is to show th logic), this creates a dataset with numbr of distinct subjects.&lt;/P&gt;
&lt;P&gt;2) &amp;nbsp;Get number of subjects with test positive:&lt;/P&gt;
&lt;PRE&gt;proc sql;
   create table POSITVE as
   select count(distinct SUBJ) as N
   from   HAVE
   where  RESULT &amp;gt; 0;
quit;&lt;/PRE&gt;
&lt;P&gt;3) &amp;nbsp;Get number of subjects with negative at 3, but not at 4 - this requires one fo two things, either retaining the V3 record down the dataset or merging that value back onto the dataset:&lt;/P&gt;
&lt;P&gt;I will do retain (assumes the data is sorted by subject visit), what this will do is create a dataset with all records not visit 3, but which contain visit 3 data in v3_value:&lt;/P&gt;
&lt;PRE&gt;data test3;
  set have;
  by subj;
  retain v3_value;
  if first.subj then v3_value=.;
  if visit=3 then v3_value=result;
  else output;
run;&lt;/PRE&gt;
&lt;P&gt;Then simply do a count:&lt;/P&gt;
&lt;PRE&gt;proc sql;
   create table WANT as
   select  count(distinct SUBJ)
   from    TEST3
   where  RESULT &amp;gt; 0 and V3_VALUE &amp;lt; 0;
quit;&lt;/PRE&gt;
&lt;P&gt;You now have your thee necessary counts, and you can merge these together, or set them together however your output requires.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Dec 2015 09:38:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-want-a-calculated-values-of-number-of-subjects/m-p/238231#M43749</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-12-08T09:38:42Z</dc:date>
    </item>
  </channel>
</rss>

