<?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: Output a value if variable is flagged in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Output-a-value-if-variable-is-flagged/m-p/647301#M22145</link>
    <description>&lt;P&gt;The array name is flg not flgs - tat was my typo;&lt;/P&gt;
&lt;P&gt;change line to&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do i=1 to dim(flg);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;-&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 13 May 2020 03:55:56 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2020-05-13T03:55:56Z</dc:date>
    <item>
      <title>Output a value if variable is flagged</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Output-a-value-if-variable-is-flagged/m-p/647269#M22136</link>
      <description>&lt;P&gt;I have a table where each biomarker has a corresponding flag variable that equals 1 if it needs to be reviewed. Is there a way to systematically output the SUBJECTID and the biomarker name and value if the variable is flagged?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 input SUBJECTID $ BLD_GGT BLD_TRIG BLD_INS BLD_GGT_FLAG BLD_TRIG_FLAG BLD_INS_FLAG;
cards;
001 12 100 43 0 0 1
002 12 99 42 0 0 0
003 15 104 30 0 0 0
004 3  109 24 1 1 0
005 14 100 23 0 0 0 
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
input SUBJECTID $ VARIABLE $ VALUE;
cards;
001 BLD_INS 43
004 BLD_GGT 15
004 BLD_TRIG 109
;
run; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 May 2020 23:54:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Output-a-value-if-variable-is-flagged/m-p/647269#M22136</guid>
      <dc:creator>bkq32</dc:creator>
      <dc:date>2020-05-12T23:54:27Z</dc:date>
    </item>
    <item>
      <title>Re: Output a value if variable is flagged</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Output-a-value-if-variable-is-flagged/m-p/647272#M22137</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/288620"&gt;@bkq32&lt;/a&gt;&amp;nbsp; Methinks your HAVE has value ambiguity or a typo. So i modified your HAVE&amp;nbsp;with that assumption&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 input SUBJECTID $ BLD_GGT BLD_TRIG BLD_INS BLD_GGT_FLAG BLD_TRIG_FLAG BLD_INS_FLAG;
cards;
001 12 100 43 0 0 1
002 12 99 42 0 0 0
003 15 104 30 1 0 0
004 3  109 24 0 1 0
005 14 100 23 0 0 0 
;
run;

data want;
 set have;
 array b  BLD_GGT BLD_TRIG BLD_INS;
 array f BLD_GGT_FLAG BLD_TRIG_FLAG BLD_INS_FLAG;
 _n_=whichn(1,of f(*));
 if _n_;
 variable=vname(b(_n_));
 value=b(_n_);
 keep subjectid variable value;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 May 2020 00:15:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Output-a-value-if-variable-is-flagged/m-p/647272#M22137</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-05-13T00:15:43Z</dc:date>
    </item>
    <item>
      <title>Re: Output a value if variable is flagged</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Output-a-value-if-variable-is-flagged/m-p/647274#M22139</link>
      <description>&lt;P&gt;Try next code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
 set have;
     length variable $15; /* addapt to max variable name length */
     array flg BLD_GGT_FLAG BLD_TRIG_FLAG BLD_INS_FLAG;
	 array bio BLD_GGT      BLD_TRIG      BLD_INS;
	 do i=1 to dim(flg);
	    if flg(i)=1 then do;
		   variable = vname(bio(i));
		   value = bio(i);
		   output;
		end;
	 end;
	 keep subjectid variable value;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 May 2020 04:20:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Output-a-value-if-variable-is-flagged/m-p/647274#M22139</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-05-13T04:20:25Z</dc:date>
    </item>
    <item>
      <title>Re: Output a value if variable is flagged</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Output-a-value-if-variable-is-flagged/m-p/647278#M22141</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;, The original HAVE table was correct since some records will have more than one flag, in which case I'd like to create separate records for them in WANT with the variable name and value for each of those biomarkers. Is there a way to do that?&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 00:59:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Output-a-value-if-variable-is-flagged/m-p/647278#M22141</guid>
      <dc:creator>bkq32</dc:creator>
      <dc:date>2020-05-13T00:59:20Z</dc:date>
    </item>
    <item>
      <title>Re: Output a value if variable is flagged</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Output-a-value-if-variable-is-flagged/m-p/647279#M22142</link>
      <description>&lt;P&gt;Thank you,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt;.&amp;nbsp;When I tried running that code, I go this error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;411 data want;&lt;BR /&gt;412 set have;&lt;BR /&gt;413 length variable $15; /* addapt to max variable name&lt;BR /&gt;413! length */&lt;BR /&gt;414 array flg BLD_GGT_FLAG BLD_TRIG_FLAG BLD_INS_FLAG;&lt;BR /&gt;415 array bio BLD_GGT BLD_TRIG BLD_INS;&lt;BR /&gt;416 do i=1 to dim(flgs);&lt;BR /&gt;ERROR: The DIM, LBOUND, and HBOUND functions require an array&lt;BR /&gt;name for the first argument.&lt;BR /&gt;417 if flg(i)=1 then do;&lt;BR /&gt;418 variable = vname(bio(i));&lt;BR /&gt;419 value = bio(i);&lt;BR /&gt;420 output;&lt;BR /&gt;421 end;&lt;BR /&gt;422 end;&lt;BR /&gt;423 keep subjectid variable value;&lt;BR /&gt;424 run;&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 01:00:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Output-a-value-if-variable-is-flagged/m-p/647279#M22142</guid>
      <dc:creator>bkq32</dc:creator>
      <dc:date>2020-05-13T01:00:49Z</dc:date>
    </item>
    <item>
      <title>Re: Output a value if variable is flagged</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Output-a-value-if-variable-is-flagged/m-p/647282#M22143</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/288620"&gt;@bkq32&lt;/a&gt;&amp;nbsp; Alright. Can you explain how this result qualifies ?&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;004 BLD_GGT 15&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 01:34:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Output-a-value-if-variable-is-flagged/m-p/647282#M22143</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-05-13T01:34:20Z</dc:date>
    </item>
    <item>
      <title>Re: Output a value if variable is flagged</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Output-a-value-if-variable-is-flagged/m-p/647289#M22144</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;A clinician might've told me to run something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if BLD_GGT&amp;gt;14 then BLD_GGT_FLAG=1;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 May 2020 02:02:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Output-a-value-if-variable-is-flagged/m-p/647289#M22144</guid>
      <dc:creator>bkq32</dc:creator>
      <dc:date>2020-05-13T02:02:54Z</dc:date>
    </item>
    <item>
      <title>Re: Output a value if variable is flagged</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Output-a-value-if-variable-is-flagged/m-p/647301#M22145</link>
      <description>&lt;P&gt;The array name is flg not flgs - tat was my typo;&lt;/P&gt;
&lt;P&gt;change line to&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do i=1 to dim(flg);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;-&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 03:55:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Output-a-value-if-variable-is-flagged/m-p/647301#M22145</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-05-13T03:55:56Z</dc:date>
    </item>
    <item>
      <title>Re: Output a value if variable is flagged</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Output-a-value-if-variable-is-flagged/m-p/647302#M22146</link>
      <description>Thank you!</description>
      <pubDate>Wed, 13 May 2020 04:02:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Output-a-value-if-variable-is-flagged/m-p/647302#M22146</guid>
      <dc:creator>bkq32</dc:creator>
      <dc:date>2020-05-13T04:02:02Z</dc:date>
    </item>
  </channel>
</rss>

