<?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: visit and ranges in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/visit-and-ranges/m-p/277747#M55810</link>
    <description>&lt;P&gt;There is certainly a simpler way to achieve this. What is the link between &lt;EM&gt;week&lt;/EM&gt; and &lt;EM&gt;winLow&lt;/EM&gt;?&lt;/P&gt;</description>
    <pubDate>Thu, 16 Jun 2016 03:04:18 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2016-06-16T03:04:18Z</dc:date>
    <item>
      <title>visit and ranges</title>
      <link>https://communities.sas.com/t5/SAS-Programming/visit-and-ranges/m-p/277712#M55795</link>
      <description>&lt;P&gt;Dear All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to create a dataset with vist and ranges.&amp;nbsp; some where i am getting wrong. Any insight or better approach will be helpful&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let week=1 3 7 11 15 17 18 19 20 23 27 31 35 39 43 48 52;&lt;BR /&gt;%let winlow=0 2 37 65 93 114 124 131 138 152 177 205 233 261 289 320 352;&lt;BR /&gt;%let winhi=1 36 64 92 113 123 130 137 151 176 204 232 260 288 319 351 370;&lt;BR /&gt;%macro win;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; %do i=1 %to %sysfunc(countw(&amp;amp;week));&lt;BR /&gt;&amp;nbsp;&amp;nbsp; %let vis=%scan(&amp;amp;week,&amp;amp;i); %let low=%scan(&amp;amp;winlow,&amp;amp;i); %let hi=%scan(&amp;amp;winhi,&amp;amp;i);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; data t;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;vis=&amp;amp;vis;winlow=&amp;amp;low;winhi=&amp;amp;hi;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; run;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; %end;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; proc append base=visrange data=t force;run;&lt;BR /&gt;&amp;nbsp;%mend;&lt;BR /&gt;&amp;nbsp;%win;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Cathy&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:20:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/visit-and-ranges/m-p/277712#M55795</guid>
      <dc:creator>cathy_sas</dc:creator>
      <dc:date>2016-06-15T23:20:29Z</dc:date>
    </item>
    <item>
      <title>Re: visit and ranges</title>
      <link>https://communities.sas.com/t5/SAS-Programming/visit-and-ranges/m-p/277715#M55797</link>
      <description>&lt;P&gt;The location of your loop doesn't make sense. Remember that macro just generates code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So at i=1 you get:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; data t;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;vis=1;winlow=0;winhi=1;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;But at i=2 you get&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp; data t;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;vis=3;winlow=2;winhi=36;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; run;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;However this is within the same loop so you've overwritten your data set t, and your append doesn't do much.&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;If you want to fix it move the %end to after your proc append, not after data step.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;I &lt;U&gt;&lt;STRONG&gt;would suggest&lt;/STRONG&gt;&lt;/U&gt; moving this all into a data step without macro/macro loops. This is untested. Make sure the variables are long enough to hold your macro variable list.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  data t;
   length vis_list winlow_list winhi_list $2000.;
    vis_list = "&amp;amp;vis";
    winlow_list = "&amp;amp;winlow";
    winhi_list = "&amp;amp;winhi";

    n_count = countw(vis_list);

   do i=1 to n_count;
        week=scan(vis_list, i);
        win_low = scan(winlow_list, i);
        winhi_list = scan(winhi_list, i);
        OUTPUT;
    end;

   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:51:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/visit-and-ranges/m-p/277715#M55797</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-06-15T23:51:23Z</dc:date>
    </item>
    <item>
      <title>Re: visit and ranges</title>
      <link>https://communities.sas.com/t5/SAS-Programming/visit-and-ranges/m-p/277747#M55810</link>
      <description>&lt;P&gt;There is certainly a simpler way to achieve this. What is the link between &lt;EM&gt;week&lt;/EM&gt; and &lt;EM&gt;winLow&lt;/EM&gt;?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2016 03:04:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/visit-and-ranges/m-p/277747#M55810</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-06-16T03:04:18Z</dc:date>
    </item>
    <item>
      <title>Re: visit and ranges</title>
      <link>https://communities.sas.com/t5/SAS-Programming/visit-and-ranges/m-p/277749#M55811</link>
      <description>&lt;P&gt;hi pgstat,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a variable days in dataset. and in data presentation plan, we have ranges , if days fall under these days i need to create a week and visit variables&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;for example : in data presentation plan&lt;/P&gt;
&lt;P&gt;%let winlow=0 2 37 65 93 114 124 131 138 152 177 205 233 261 289 320 352;&lt;BR /&gt;%let winhi=1 36 64 92 113 123 130 137 151 176 204 232 260 288 319 351 370;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and a days variable like 1,22,50,7,106,120,127,134,141,162,190,218,246,274,302,337,360&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;need to create week and visitnum based on the ranges&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Cathy&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2016 03:14:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/visit-and-ranges/m-p/277749#M55811</guid>
      <dc:creator>cathy_sas</dc:creator>
      <dc:date>2016-06-16T03:14:18Z</dc:date>
    </item>
    <item>
      <title>Re: visit and ranges</title>
      <link>https://communities.sas.com/t5/SAS-Programming/visit-and-ranges/m-p/277752#M55813</link>
      <description>&lt;P&gt;If the problem is to translate day numbers into ranges, you could do something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data days;
input day @@;
datalines;
1 22 50 7 106 120 127 134 141 162 190 218 246 274 302 337 360
;

data t;
array lo{20} _temporary_ 
(0 2 37 65 93 114 124 131 138 152 177 205 233 261 289 320 352);
array hi{20} _temporary_ 
(1 36 64 92 113 123 130 137 151 176 204 232 260 288 319 351 370);
array w{20} _temporary_
(1 3 7 11 15 17 18 19 20 23 27 31 35 39 43 48 52);
set days;
do weekNum = 1 by 1 while(day &amp;gt; hi{weekNum}); end;
week = w{weekNum};
weekLow = lo{weekNum};
weekHi = hi{weekNum};
run;

proc print; run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Jun 2016 03:41:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/visit-and-ranges/m-p/277752#M55813</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-06-16T03:41:12Z</dc:date>
    </item>
  </channel>
</rss>

