<?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: Use array to conditionally set values of merged data to missing in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Use-array-to-conditionally-set-values-of-merged-data-to-missing/m-p/541731#M149634</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much for your quick response.&amp;nbsp; This is exactly what I was looking for.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ted&lt;/P&gt;</description>
    <pubDate>Sat, 09 Mar 2019 20:05:30 GMT</pubDate>
    <dc:creator>LEINAARE</dc:creator>
    <dc:date>2019-03-09T20:05:30Z</dc:date>
    <item>
      <title>Use array to conditionally set values of merged data to missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-array-to-conditionally-set-values-of-merged-data-to-missing/m-p/541725#M149628</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two datasets I want to merge.&amp;nbsp; Both are very large (observations in the millions).&amp;nbsp; Dataset1 contains Medicaid user information and a flag to indicate whether or not they are eligible for study inclusion &lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #333333; cursor: text; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;(name of flag is "eligible")&lt;/SPAN&gt;.&amp;nbsp; Dataset2 contains Medicaid claims data.&amp;nbsp; Dataset1 contains individuals who are eligible for study inclusion at any time during the 5-year duration of our study.&amp;nbsp; I need to keep all observations in Dataset1, even if they are not eligible for study inclusion for a given observation (i.e. eligible=0).&amp;nbsp; However, I only want the claims data from Dataset2 to merge with Dataset1 if the eligible = 1.&amp;nbsp; Otherwise, I need the values in Dataset2 to be missing.&amp;nbsp; Also, there is claims data in Dataset2 that is not associated with individuals in Dataset1.&amp;nbsp; I want to only keep claims from Dataset2 that are associated with individuals in Dataset1, and only at times when their eligibility flag=1.&amp;nbsp; Below is simplified version of my code to provide an example of what I am trying to do conceptually (the actual code is very long).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data merged_claims;
     merge Dataset1 (in=a)
          Dataset2 (in=b);
     by ID Date;
     if a=1;
     ClaimFlag=0;
     MedicalFlag=0;
     if b=1 and eligible=1 then do;
          ClaimFlag=1;
          MedicalFlag=1;
     end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I would like to include code that would set values of variables in Dataset2 to missing if ClaimFlag=0.&amp;nbsp; Dataset2 has over 50 variables, both character and numeric.&amp;nbsp; I could hard code it using a do statement and specify for each variable a missing value according to whether it is character or numeric, but it seems like an array would be much smarter to use for so many variables.&amp;nbsp; Can anyone offer a suggestion how to use an array to set character and numeric values to missing wherever eligible=0?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Sat, 09 Mar 2019 19:41:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-array-to-conditionally-set-values-of-merged-data-to-missing/m-p/541725#M149628</guid>
      <dc:creator>LEINAARE</dc:creator>
      <dc:date>2019-03-09T19:41:54Z</dc:date>
    </item>
    <item>
      <title>Re: Use array to conditionally set values of merged data to missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-array-to-conditionally-set-values-of-merged-data-to-missing/m-p/541728#M149631</link>
      <description>&lt;P&gt;You have to declare two arrays, one for the numerics and one for character and then you can use call missing. You can also use other variables lists if they apply.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Examples of variable lists can be found here:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this example I'm using the start and end of a list of variables which will take all numeric variables between a start and end variable based on their order in the dataset.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array _num(*) startVar-numeric-endVar;
array _char(*) startVar-character-endVar;

if eligible = 0 then call missing(of _num(*), of _char(*));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/203435"&gt;@LEINAARE&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have two datasets I want to merge.&amp;nbsp; Both are very large (observations in the millions).&amp;nbsp; Dataset1 contains Medicaid user information and a flag to indicate whether or not they are eligible for study inclusion &lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #333333; cursor: text; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;(name of flag is "eligible")&lt;/SPAN&gt;.&amp;nbsp; Dataset2 contains Medicaid claims data.&amp;nbsp; Dataset1 contains individuals who are eligible for study inclusion at any time during the 5-year duration of our study.&amp;nbsp; I need to keep all observations in Dataset1, even if they are not eligible for study inclusion for a given observation (i.e. eligible=0).&amp;nbsp; However, I only want the claims data from Dataset2 to merge with Dataset1 if the eligible = 1.&amp;nbsp; Otherwise, I need the values in Dataset2 to be missing.&amp;nbsp; Also, there is claims data in Dataset2 that is not associated with individuals in Dataset1.&amp;nbsp; I want to only keep claims from Dataset2 that are associated with individuals in Dataset1, and only at times when their eligibility flag=1.&amp;nbsp; Below is simplified version of my code to provide an example of what I am trying to do conceptually (the actual code is very long).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data merged_claims;
     merge Dataset1 (in=a)
          Dataset2 (in=b);
     by ID Date;
     if a=1;
     ClaimFlag=0;
     MedicalFlag=0;
     if b=1 and eligible=1 then do;
          ClaimFlag=1;
          MedicalFlag=1;
     end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I would like to include code that would set values of variables in Dataset2 to missing if ClaimFlag=0.&amp;nbsp; Dataset2 has over 50 variables, both character and numeric.&amp;nbsp; I could hard code it using a do statement and specify for each variable a missing value according to whether it is character or numeric, but it seems like an array would be much smarter to use for so many variables.&amp;nbsp; Can anyone offer a suggestion how to use an array to set character and numeric values to missing wherever eligible=0?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Mar 2019 19:50:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-array-to-conditionally-set-values-of-merged-data-to-missing/m-p/541728#M149631</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-03-09T19:50:45Z</dc:date>
    </item>
    <item>
      <title>Re: Use array to conditionally set values of merged data to missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-array-to-conditionally-set-values-of-merged-data-to-missing/m-p/541731#M149634</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much for your quick response.&amp;nbsp; This is exactly what I was looking for.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ted&lt;/P&gt;</description>
      <pubDate>Sat, 09 Mar 2019 20:05:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-array-to-conditionally-set-values-of-merged-data-to-missing/m-p/541731#M149634</guid>
      <dc:creator>LEINAARE</dc:creator>
      <dc:date>2019-03-09T20:05:30Z</dc:date>
    </item>
  </channel>
</rss>

