<?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: By Group -- Replace a var's values based on another variables specific value in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/By-Group-Replace-a-var-s-values-based-on-another-variables/m-p/162901#M42291</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check this *** Not tested&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data new ;&lt;/P&gt;&lt;P&gt;infile datalines dlm=',';&lt;/P&gt;&lt;P&gt;input STATUS $;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;C,&lt;/P&gt;&lt;P&gt;C,&lt;/P&gt;&lt;P&gt;,&lt;/P&gt;&lt;P&gt;V,&lt;/P&gt;&lt;P&gt;V,&lt;/P&gt;&lt;P&gt;,&lt;/P&gt;&lt;P&gt;,&lt;/P&gt;&lt;P&gt;V,&lt;/P&gt;&lt;P&gt;,&lt;/P&gt;&lt;P&gt;C,&lt;/P&gt;&lt;P&gt;,&lt;/P&gt;&lt;P&gt;,&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data newC;&lt;/P&gt;&lt;P&gt;retain newV ' ';&lt;/P&gt;&lt;P&gt;set new;&lt;/P&gt;&lt;P&gt;if _n_=1 and STATUS = ' ' then Do ;&lt;/P&gt;&lt;P&gt;*STATUS = 'V';&lt;/P&gt;&lt;P&gt;newV='V';&lt;/P&gt;&lt;P&gt;End;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Else if STATUS in ('C','V') then newV=STATUS;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;*Else if STATUS=' ' then STATUS=newV;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 28 Sep 2014 10:00:56 GMT</pubDate>
    <dc:creator>mohamed_zaki</dc:creator>
    <dc:date>2014-09-28T10:00:56Z</dc:date>
    <item>
      <title>By Group -- Replace a var's values based on another variables specific value</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/By-Group-Replace-a-var-s-values-based-on-another-variables/m-p/162899#M42289</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;Dear all,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;In a by group I have&amp;nbsp; missing values in &lt;SPAN class="GINGER_SOFTWARE_mark" id="143a3ddf-3802-4cee-b04b-aa7aa7d78b00"&gt;&lt;SPAN class="GINGER_SOFTWARE_mark" id="a2b5225c-8924-4199-bd1f-7e4b83883ff7"&gt;variable STATUS&lt;/SPAN&gt;&lt;/SPAN&gt;&amp;nbsp; for&amp;nbsp; various Trade_Quarters.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;I would like to replace the STATUS missing values based on the following:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;If STATUS = 'C' (=cancelled) then if any&amp;nbsp; &lt;SPAN style="text-decoration: underline;"&gt;&lt;SPAN style="color: #575757; text-decoration: underline;"&gt;SUBSEQUENT&lt;/SPAN&gt;&lt;/SPAN&gt; TRADE_QUARTERS take STATUS ='C'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;If STATUS = 'C' (=cancelled) then if any &lt;SPAN style="text-decoration: underline;"&gt;PRIOR&lt;/SPAN&gt;&amp;nbsp; &lt;SPAN style="font-family: Arial, sans-serif;"&gt;TRADE_QUARTERS&lt;/SPAN&gt; take STATUS = 'V'&amp;nbsp; (=Valid)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;If there is no STATUS = 'C' then &lt;SPAN style="text-decoration: underline;"&gt;ALL&lt;/SPAN&gt; values of STATUS become = 'V'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial, sans-serif;"&gt;&lt;SPAN class="GINGER_SOFTWARE_mark" id="4aa7db1f-f4f2-404d-a439-4ae6aca01934"&gt;&lt;SPAN class="GINGER_SOFTWARE_mark" id="dfc0972b-cca3-4f5d-a6e8-fd4e270aae59"&gt;Pls&lt;/SPAN&gt;&lt;/SPAN&gt;. &lt;SPAN class="GINGER_SOFTWARE_mark" id="aa0b8146-9a76-46cf-ba53-cc1fdb948ac8"&gt;&lt;SPAN class="GINGER_SOFTWARE_mark" id="c7fb5613-4acb-4ea7-bb3c-d3c0f7ec1b7e"&gt;see&lt;/SPAN&gt;&lt;/SPAN&gt; data HAVE and WANT in the attached file.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial, sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial, sans-serif;"&gt;Thanking you in advance for any hint.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial, sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial, sans-serif;"&gt;Kind regards&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial, sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial, sans-serif;"&gt;Nikos&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial, sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/11543i514D7DBAD1A522C3/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="bygroupreplacemissing.png" title="bygroupreplacemissing.png" /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 28 Sep 2014 08:48:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/By-Group-Replace-a-var-s-values-based-on-another-variables/m-p/162899#M42289</guid>
      <dc:creator>Nikos</dc:creator>
      <dc:date>2014-09-28T08:48:02Z</dc:date>
    </item>
    <item>
      <title>Re: By Group -- Replace a var's values based on another variables specific value</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/By-Group-Replace-a-var-s-values-based-on-another-variables/m-p/162900#M42290</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN class="GINGER_SOFTWARE_mark" id="4d3e4e9a-7057-4c99-83b3-6a070f69aca9"&gt;just&lt;/SPAN&gt; a typo&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="GINGER_SOFTWARE_mark" id="3803d172-4d49-48c5-bc91-1e138591ae5e"&gt;in&lt;/SPAN&gt; the last by group: where &lt;STRONG&gt;'O'&lt;/STRONG&gt; should be replaced with '&lt;STRONG&gt;V'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 28 Sep 2014 08:54:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/By-Group-Replace-a-var-s-values-based-on-another-variables/m-p/162900#M42290</guid>
      <dc:creator>Nikos</dc:creator>
      <dc:date>2014-09-28T08:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: By Group -- Replace a var's values based on another variables specific value</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/By-Group-Replace-a-var-s-values-based-on-another-variables/m-p/162901#M42291</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check this *** Not tested&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data new ;&lt;/P&gt;&lt;P&gt;infile datalines dlm=',';&lt;/P&gt;&lt;P&gt;input STATUS $;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;C,&lt;/P&gt;&lt;P&gt;C,&lt;/P&gt;&lt;P&gt;,&lt;/P&gt;&lt;P&gt;V,&lt;/P&gt;&lt;P&gt;V,&lt;/P&gt;&lt;P&gt;,&lt;/P&gt;&lt;P&gt;,&lt;/P&gt;&lt;P&gt;V,&lt;/P&gt;&lt;P&gt;,&lt;/P&gt;&lt;P&gt;C,&lt;/P&gt;&lt;P&gt;,&lt;/P&gt;&lt;P&gt;,&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data newC;&lt;/P&gt;&lt;P&gt;retain newV ' ';&lt;/P&gt;&lt;P&gt;set new;&lt;/P&gt;&lt;P&gt;if _n_=1 and STATUS = ' ' then Do ;&lt;/P&gt;&lt;P&gt;*STATUS = 'V';&lt;/P&gt;&lt;P&gt;newV='V';&lt;/P&gt;&lt;P&gt;End;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Else if STATUS in ('C','V') then newV=STATUS;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;*Else if STATUS=' ' then STATUS=newV;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 28 Sep 2014 10:00:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/By-Group-Replace-a-var-s-values-based-on-another-variables/m-p/162901#M42291</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2014-09-28T10:00:56Z</dc:date>
    </item>
    <item>
      <title>Re: By Group -- Replace a var's values based on another variables specific value</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/By-Group-Replace-a-var-s-values-based-on-another-variables/m-p/162902#M42292</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;the previous one to see the change but the final code should be like the following"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data newC (drop=&lt;SPAN style="font-size: 13.6000003814697px;"&gt;newV&lt;/SPAN&gt; );&lt;/P&gt;&lt;P&gt;retain newV ' ';&lt;/P&gt;&lt;P&gt;set new;&lt;/P&gt;&lt;P&gt;if _n_=1 and STATUS = ' ' then Do ;&lt;/P&gt;&lt;P&gt;STATUS = 'V';&lt;/P&gt;&lt;P&gt;newV=STATUS;&lt;/P&gt;&lt;P&gt;End;&lt;/P&gt;&lt;P&gt;Else if STATUS in ('C','V') then newV=STATUS;&lt;/P&gt;&lt;P&gt;Else if STATUS=' ' then STATUS=newV;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 28 Sep 2014 10:17:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/By-Group-Replace-a-var-s-values-based-on-another-variables/m-p/162902#M42292</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2014-09-28T10:17:29Z</dc:date>
    </item>
  </channel>
</rss>

