<?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: rename unscheduled visit sequentially in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/rename-unscheduled-visit-sequentially/m-p/328784#M73447</link>
    <description>Thanks for the CAT function.</description>
    <pubDate>Tue, 31 Jan 2017 15:51:28 GMT</pubDate>
    <dc:creator>fengyuwuzu</dc:creator>
    <dc:date>2017-01-31T15:51:28Z</dc:date>
    <item>
      <title>rename unscheduled visit sequentially</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rename-unscheduled-visit-sequentially/m-p/328751#M73439</link>
      <description>&lt;P&gt;in my data, for the same person with unscheduled visits, they are all coded as 99.1 (visit number) and "Unscheduled 1" (visit name).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to recode the second one as 99.2 and 'Unscheduled 2', the third one as 99.2 and 'Unscheduled 3', etc.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data unvisit2 ;
set unvisit1;
by usubjid visit vsdt;&lt;BR /&gt;i=1;
if first.visit then i=1;
else do;
 i=i+1;
 visitnum=visitnum+0.1;
 visit='UNSCHEDULED ' || strip(put(i,best.));
end;&lt;BR /&gt;drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a better way to do it?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2017 14:53:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rename-unscheduled-visit-sequentially/m-p/328751#M73439</guid>
      <dc:creator>fengyuwuzu</dc:creator>
      <dc:date>2017-01-31T14:53:50Z</dc:date>
    </item>
    <item>
      <title>Re: rename unscheduled visit sequentially</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rename-unscheduled-visit-sequentially/m-p/328753#M73440</link>
      <description>&lt;P&gt;If your VSDT variable is a date then I don't see much that could be done.&lt;/P&gt;
&lt;P&gt;I might be concerned that you are setting all visits to Unscheduled except the first one, but you know your data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would probably replace visit&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'UNSCHEDULED '&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;||&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;strip&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;put&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;i&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;best&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;with&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;visit = catx(' ','UNSCHEDULED',i);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2017 15:01:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rename-unscheduled-visit-sequentially/m-p/328753#M73440</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-01-31T15:01:52Z</dc:date>
    </item>
    <item>
      <title>Re: rename unscheduled visit sequentially</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rename-unscheduled-visit-sequentially/m-p/328757#M73441</link>
      <description>&lt;P&gt;Well, does your code work? &amp;nbsp;i is not retained across rows, so it will aways be . when you start. &amp;nbsp;AS you haven't provided any test data (in the form of a datastep) I can't give working code, but something like:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  retain visitnum;
  if visit="Unscheduled" then visitnum=visitnum+0.1;
  visit=ifc(first.visit,"Unscheduled 1",catx(" ","Unscheduled",put(visitnum,best.)));
run;
  
&lt;/PRE&gt;</description>
      <pubDate>Tue, 31 Jan 2017 15:07:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rename-unscheduled-visit-sequentially/m-p/328757#M73441</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-01-31T15:07:41Z</dc:date>
    </item>
    <item>
      <title>Re: rename unscheduled visit sequentially</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rename-unscheduled-visit-sequentially/m-p/328783#M73446</link>
      <description>&lt;P&gt;Thank you for your comments. My code&amp;nbsp;has a problem, that the third one is also coded 99.2.&lt;/P&gt;
&lt;P&gt;Without the i=1; statement before the if statement, i will be missing for non-first ones.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2017 16:42:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rename-unscheduled-visit-sequentially/m-p/328783#M73446</guid>
      <dc:creator>fengyuwuzu</dc:creator>
      <dc:date>2017-01-31T16:42:14Z</dc:date>
    </item>
    <item>
      <title>Re: rename unscheduled visit sequentially</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rename-unscheduled-visit-sequentially/m-p/328784#M73447</link>
      <description>Thanks for the CAT function.</description>
      <pubDate>Tue, 31 Jan 2017 15:51:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rename-unscheduled-visit-sequentially/m-p/328784#M73447</guid>
      <dc:creator>fengyuwuzu</dc:creator>
      <dc:date>2017-01-31T15:51:28Z</dc:date>
    </item>
    <item>
      <title>Re: rename unscheduled visit sequentially</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rename-unscheduled-visit-sequentially/m-p/328817#M73467</link>
      <description>&lt;P&gt;I did not even see this, this is a good example of why badly formatted code is hard to read. &amp;nbsp;Try:&lt;/P&gt;
&lt;PRE&gt;data unvisit2 (drop=i);
  set unvisit1;
  by usubjid visit vsdt;
  i=1;
  if not(first.visit) then do;
    i=i+1;
    visitnum=visitnum+0.1;
    visit=catx(" ",'UNSCHEDULED',put(i,best.));
  end;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 31 Jan 2017 17:01:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rename-unscheduled-visit-sequentially/m-p/328817#M73467</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-01-31T17:01:34Z</dc:date>
    </item>
  </channel>
</rss>

