<?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 conditionally code a cell to include a value that depends on a variable? ex inside in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-conditionally-code-a-cell-to-include-a-value-that-depends/m-p/811764#M320220</link>
    <description>&lt;P&gt;What would target_eye be if both glaucoma_r and glaucoma_l were both Y or both N?&lt;/P&gt;</description>
    <pubDate>Thu, 05 May 2022 21:49:25 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2022-05-05T21:49:25Z</dc:date>
    <item>
      <title>How to conditionally code a cell to include a value that depends on a variable? ex inside</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-conditionally-code-a-cell-to-include-a-value-that-depends/m-p/811761#M320218</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have1;
infile datalines dsd dlm=",";
	input usubjid $ visit $ glaucoma  $ glaucoma_r $ glaucoma_l $ target_eye;
datalines;
001, a, , Y, N, 2
001, b, Y, , , 2
001, c, Y, , , 2
001, d, Y, , , 2
001, e, N, , , 2
002, a, , N, Y, 1
002, b, Y, , , 1
002, c, Y, , , 1
002, d, Y, , , 1
002, e, N, , , 1
run; * target eye 1=left, 2=right;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Notes:&lt;/P&gt;
&lt;P&gt;- There are 2 subjects here and 5 visits.&lt;/P&gt;
&lt;P&gt;- The first visit (A) is screening, and the data doesn't show up there GLAUCOMA. But does appear for GLAUCOMA_R GLAUCOMA_L. This is bc data was capture at screening for both eyes.&lt;/P&gt;
&lt;P&gt;- Every subsequent visit, data was only collected for the target eye.So that is why values populate for GLAUCOMA for visit B (dosing) and onwards, but not for the other two columns for GLAUCOMA_R and GLAUCOMA_L.&lt;/P&gt;
&lt;P&gt;-&amp;nbsp; TARGET_EYE is coded so that the 1=left and 2=right. So for the first subject, i want for that person's row for Visit A to be value for GLAUCOMA_R, since their target_eye value is 2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is what the desired output should look like:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Hello_there_0-1651786678938.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/71167i8B79DADF86A5E2A2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Hello_there_0-1651786678938.png" alt="Hello_there_0-1651786678938.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Note that for Visit A rows, 2 cells that were missing in GLAUCOMA now are filled when before they were empty. Also note, although not relevant, that the two subjects had their issues resolved by the fifth and final visit (visit e).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 05 May 2022 21:40:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-conditionally-code-a-cell-to-include-a-value-that-depends/m-p/811761#M320218</guid>
      <dc:creator>Hello_there</dc:creator>
      <dc:date>2022-05-05T21:40:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to conditionally code a cell to include a value that depends on a variable? ex inside</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-conditionally-code-a-cell-to-include-a-value-that-depends/m-p/811764#M320220</link>
      <description>&lt;P&gt;What would target_eye be if both glaucoma_r and glaucoma_l were both Y or both N?&lt;/P&gt;</description>
      <pubDate>Thu, 05 May 2022 21:49:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-conditionally-code-a-cell-to-include-a-value-that-depends/m-p/811764#M320220</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-05-05T21:49:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to conditionally code a cell to include a value that depends on a variable? ex inside</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-conditionally-code-a-cell-to-include-a-value-that-depends/m-p/811765#M320221</link>
      <description>Good question. It would just be whatever eye the experimenter wants to test, either left or right.</description>
      <pubDate>Thu, 05 May 2022 21:53:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-conditionally-code-a-cell-to-include-a-value-that-depends/m-p/811765#M320221</guid>
      <dc:creator>Hello_there</dc:creator>
      <dc:date>2022-05-05T21:53:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to conditionally code a cell to include a value that depends on a variable? ex inside</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-conditionally-code-a-cell-to-include-a-value-that-depends/m-p/811766#M320222</link>
      <description>&lt;P&gt;Try this. It gives the same answer you've provided. If both glaucoma variables are N or Y then I set target_eye2 to missing for now.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data = have1;
  by usubjid visit;
run;

data want;
  set have1;
  by usubjid;
  retain target_eye2;
  if first.usubjid and visit = 'a' then do;
    if glaucoma_l = 'Y' and glaucoma_r = 'N' then target_eye2 = 1;
    else if glaucoma_l = 'N' and glaucoma_r = 'Y' then target_eye2 = 2;
    else target_eye2 = .;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 May 2022 22:04:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-conditionally-code-a-cell-to-include-a-value-that-depends/m-p/811766#M320222</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-05-05T22:04:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to conditionally code a cell to include a value that depends on a variable? ex inside</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-conditionally-code-a-cell-to-include-a-value-that-depends/m-p/811774#M320227</link>
      <description>&lt;P&gt;Hey, thanks for the response!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I found another way that i think does the trick. Here you go, in case you are interested.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data visit_a; set have1;
	if visit eq "a";
	if target_eye=1 then glaucoma=glaucoma_l; else glaucoma=glaucoma_r;
run;

data other_visits; set have1;
	if visit ne "a";
run;

data want; set visit_a other_visits;
run;
proc sort; by usubjid visit; run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thanks for answering!&lt;/P&gt;</description>
      <pubDate>Thu, 05 May 2022 23:00:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-conditionally-code-a-cell-to-include-a-value-that-depends/m-p/811774#M320227</guid>
      <dc:creator>Hello_there</dc:creator>
      <dc:date>2022-05-05T23:00:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to conditionally code a cell to include a value that depends on a variable? ex inside</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-conditionally-code-a-cell-to-include-a-value-that-depends/m-p/811775#M320228</link>
      <description>&lt;P&gt;Looks like I misinterpreted your question. You wanted to derive the glaucoma variable from target_eye and not the other way around. As long as you got the answer you wanted...&lt;/P&gt;</description>
      <pubDate>Thu, 05 May 2022 23:36:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-conditionally-code-a-cell-to-include-a-value-that-depends/m-p/811775#M320228</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-05-05T23:36:08Z</dc:date>
    </item>
  </channel>
</rss>

