<?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 Dim function - need help understanding in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Dim-function-need-help-understanding/m-p/63555#M18074</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your understanding is correct but, in this case, dim(newvar) is equal to 12.&amp;nbsp; Could it be that you are confused because the value of x, by the time it leaves the loop, is 13?&amp;nbsp; If so, that is normal, the way the do loop is stated. The loop continues until the value of x is greater than the value of dim(newvar).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 12 Sep 2011 19:40:53 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2011-09-12T19:40:53Z</dc:date>
    <item>
      <title>Dim function - need help understanding</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Dim-function-need-help-understanding/m-p/63554#M18073</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everyone. I started a new position and am going through the previous analysts code. I am not all too familiar with arrays and am trying to figure out a certain part of the script she left. &lt;/P&gt;&lt;P&gt;The areas I have a question on are followed by ************************** and an A or a B to distinguish which one I am asking a question on. &lt;/P&gt;&lt;P&gt;**********A &lt;/P&gt;&lt;P&gt;%let var = : this creates a marcro variable titled var that contains all the independent variables listed after the %let var = statement&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*********B&lt;/P&gt;&lt;P&gt;From what I have been reading, the dim function always returns a total count of the number of elements in an array dimension. I cannot seem to understand why the variable created "x" contains the number 13 when there are&lt;/P&gt;&lt;P&gt;only 12 variables listed after %let var = function. Any help that can be given is much appreciated. Thank you.&lt;/P&gt;&lt;P&gt;HyunJee&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;LIBNAME&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 10pt;"&gt; PUF &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: purple; font-size: 10pt;"&gt;"C:\Users\jhale3\Desktop\NIS"&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;OPTIONS&lt;/SPAN&gt; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;FMTSEARCH&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 10pt;"&gt; = (PUF WORK LIBRARY);;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 10pt;"&gt; in_file=puf.nisteenpuf09; &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;*--- NAME OF SAS DATASET ---*;&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 10pt;"&gt; estiap=estiapt09; &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;* --- ESTIMATION AREA VARIABLE TO USE ---*;&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 10pt;"&gt; wt=provwt; &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;* --- WEIGHT TO USE ---*;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 10pt;"&gt; var = HPVI_RECOM IMM_ANY P_NUMHPV INCPOV1 Raceethk race_k educ1 num_provr facility registry&amp;nbsp; asthma P_UTDHPV;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *******************A&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 10pt;"&gt; sas_file; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 10pt;"&gt; puf.nisteenpuf09 (keep= SEQNUMT HPVI_RECOM IMM_ANY P_NUMHPV INCPOV1&amp;nbsp; Raceethk race_k educ1 num_provr facility registry vfc_order pdat &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; provwt estiapt09 state P_UTDHPV sex); &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;/*array statement is counting the number of elements in a one-dimensional array of the number of elements in a specified dimension;*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;array&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 10pt;"&gt; newvar (*) &amp;amp;var;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 10pt;"&gt; x = &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;to&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 10pt;"&gt; Dim(newvar);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *********************B&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 10pt;"&gt; newvar(x) in (&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;77&lt;/STRONG&gt; &lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;99&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 10pt;"&gt;) &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 10pt;"&gt; newvar(x) = &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;.&lt;/STRONG&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Sep 2011 19:26:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Dim-function-need-help-understanding/m-p/63554#M18073</guid>
      <dc:creator>HyunJee</dc:creator>
      <dc:date>2011-09-12T19:26:33Z</dc:date>
    </item>
    <item>
      <title>Dim function - need help understanding</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Dim-function-need-help-understanding/m-p/63555#M18074</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your understanding is correct but, in this case, dim(newvar) is equal to 12.&amp;nbsp; Could it be that you are confused because the value of x, by the time it leaves the loop, is 13?&amp;nbsp; If so, that is normal, the way the do loop is stated. The loop continues until the value of x is greater than the value of dim(newvar).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Sep 2011 19:40:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Dim-function-need-help-understanding/m-p/63555#M18074</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-09-12T19:40:53Z</dc:date>
    </item>
    <item>
      <title>Re: Dim function - need help understanding</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Dim-function-need-help-understanding/m-p/63556#M18075</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The dim function gives you the number of variables (dimensions) present in a given array.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;These are the relevant lines in your code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-size: 10pt; font-family: 'Courier New'; color: blue;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt; var = HPVI_RECOM IMM_ANY P_NUMHPV INCPOV1 Raceethk race_k educ1 num_provr facility registry&amp;nbsp; asthma P_UTDHPV;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-size: 10pt; font-family: 'Courier New'; color: blue;"&gt;array&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt; newvar (*) &amp;amp;var;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-size: 10pt; font-family: 'Courier New'; color: blue;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt; x = &lt;/SPAN&gt;&lt;STRONG style="background-color: white; font-size: 10pt; color: teal; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt; &lt;SPAN style="background-color: white; font-size: 10pt; font-family: 'Courier New'; color: blue;"&gt;to&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt; Dim(newvar);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The array statement decalres your newvar array containing a number of dimensions (*) specified by a list of variables (&amp;amp;var).&amp;nbsp; &amp;amp;var according to your %let statement contains 12 variables so dim(newvar)=12 and your do loop with iterate from 1 to 12.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The do loop acts as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;start i=1; do stuff; i+1; check condition 1&amp;lt;=i&amp;lt;=12 (true); do stuff; i+1; check..... so ultimately i=13 and the check condition is false and the loop terminates.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Sep 2011 19:41:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Dim-function-need-help-understanding/m-p/63556#M18075</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2011-09-12T19:41:39Z</dc:date>
    </item>
    <item>
      <title>Dim function - need help understanding</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Dim-function-need-help-understanding/m-p/63557#M18076</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;**** A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Correct.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;**** B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; There may be nothing wrong with the code at all.&amp;nbsp; The do loop is from 1 to 12, and x would contain the value of 13 when it exits the do loop.&amp;nbsp; That's how do loops stop - at one past the limit in your case.&amp;nbsp; If there was genuine out-of-bound indices, SAS LOG would contain error messages.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Sep 2011 19:42:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Dim-function-need-help-understanding/m-p/63557#M18076</guid>
      <dc:creator>DLing</dc:creator>
      <dc:date>2011-09-12T19:42:57Z</dc:date>
    </item>
    <item>
      <title>Dim function - need help understanding</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Dim-function-need-help-understanding/m-p/63558#M18077</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sounds like in addition to unfamiliarity with arrays you are also unfamiliar with DO.&amp;nbsp; For a really nice treatment of the subject see.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://analytics.ncsu.edu/sesug/2002/TU05.pdf"&gt;http://analytics.ncsu.edu/sesug/2002/TU05.pdf&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Sep 2011 20:13:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Dim-function-need-help-understanding/m-p/63558#M18077</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2011-09-12T20:13:12Z</dc:date>
    </item>
    <item>
      <title>Dim function - need help understanding</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Dim-function-need-help-understanding/m-p/63559#M18078</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Thank you everyone for your help and advice in regard to my question. This is exactly what I needed to know. Thank you again!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Sep 2011 13:14:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Dim-function-need-help-understanding/m-p/63559#M18078</guid>
      <dc:creator>HyunJee</dc:creator>
      <dc:date>2011-09-13T13:14:27Z</dc:date>
    </item>
    <item>
      <title>Dim function - need help understanding</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Dim-function-need-help-understanding/m-p/63560#M18079</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; this is a create resource. It is has been quite sometime since I have dealt with arrays and DO loops. this was just what I was needing!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Sep 2011 13:15:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Dim-function-need-help-understanding/m-p/63560#M18079</guid>
      <dc:creator>HyunJee</dc:creator>
      <dc:date>2011-09-13T13:15:05Z</dc:date>
    </item>
  </channel>
</rss>

