<?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: What does &amp;quot;_&amp;quot; in front of variable mean? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/What-does-quot-quot-in-front-of-variable-mean/m-p/943812#M369882</link>
    <description>&lt;P&gt;Another purpose of leading underscores in variable names (not in your example) is the avoidance of name conflicts. For example, consider a SAS macro which uses a DATA step to work with a user-supplied dataset. The developer of such a macro doesn't know the user's variable names in advance. But assuming that they don't start with an underscore or even two underscores he or she might use variable names like &lt;FONT face="courier new,courier"&gt;__i&lt;/FONT&gt;&amp;nbsp;so as to make name conflicts unlikely. With the same rationale I sometimes use such names when I suggest code here in this forum.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Similarly, some SAS procedures (e.g., PROC SUMMARY and PROC TRANSPOSE) create variable names with leading and trailing underscores. And there are the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lepg/p1kfea7go1hi5qn1beilekqz6pf2.htm" target="_blank" rel="noopener"&gt;automatic variables&lt;/A&gt; _N_, _ERROR_, _IORC_, etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(Anecdote: I remember a company's standard reporting macro which surprisingly didn't work well when a user applied it to a dataset containing &lt;EM&gt;temperature&lt;/EM&gt; data in a variable TEMP. Why? The macro developer had carelessly used that same name for a variable to store some intermediate results&amp;nbsp;&lt;EM&gt;temporarily&lt;/EM&gt;.)&lt;/P&gt;</description>
    <pubDate>Fri, 13 Sep 2024 14:41:54 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2024-09-13T14:41:54Z</dc:date>
    <item>
      <title>What does "_" in front of variable mean?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-does-quot-quot-in-front-of-variable-mean/m-p/943696#M369845</link>
      <description>&lt;P&gt;I was reading the solution here:&amp;nbsp;&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/How-to-find-the-rows-for-which-consecutive-columns-have-blank/td-p/776068" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/How-to-find-the-rows-for-which-consecutive-columns-have-blank/td-p/776068&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In his answer, there is "_count". What is the functionality of adding "_" in front of count here?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;data have;
infile cards expandtabs truncover;
input Customer	$ M1	M2	M3	M4	M5	M6	M7	M8	M9	M10	M11	M12;
cards;
A	.	94	63	106	424	252	499	356	435	469	200	423
B	.	.	.	.	.	.	.	13	137	440	75	99
C	67	118	364	.	.	.	.	.	.	156	40	415
D	430	423	.	.	.	.	54	165	26	477	129	411
;

data want;
set have;
array x{*} M: ;
count=0;
do i=1 to dim(x);
 if missing(x{i}) then count+1;
  else do;
         count=0;
		 if _count&amp;gt;5 then month=vname(x{i});
	   end;
  _count=count;
end;
drop count _count i;
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2024 20:12:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-does-quot-quot-in-front-of-variable-mean/m-p/943696#M369845</guid>
      <dc:creator>jackblack1222</dc:creator>
      <dc:date>2024-09-12T20:12:32Z</dc:date>
    </item>
    <item>
      <title>Re: What does "_" in front of variable mean?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-does-quot-quot-in-front-of-variable-mean/m-p/943698#M369846</link>
      <description>&lt;P&gt;There is no meaning.&amp;nbsp; "_" is an acceptable character to start a variable name, just like a letter.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Some people have a style preference for using an underscore as the first character of a temporary variable which they plan to drop.&amp;nbsp; But it's just a style thing, like deciding to whether to use lowercase, UPPERCASE, or camelCase for variable names.&amp;nbsp; In the SAS language, there is no meaning attached to a variable name that starts with an underscore.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the code you have shown, there are two different variables, named Count and _Count.&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The same two variables could have been named Count1 and Count2, or Count0 and Count1, or CountA and CountB, or Fred and Ginger, or ...&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2024 20:27:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-does-quot-quot-in-front-of-variable-mean/m-p/943698#M369846</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2024-09-12T20:27:55Z</dc:date>
    </item>
    <item>
      <title>Re: What does "_" in front of variable mean?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-does-quot-quot-in-front-of-variable-mean/m-p/943769#M369870</link>
      <description>&lt;P&gt;I like to use an underscore as the first character of variable names I intend to drop. You can then use a statement like this to get rid of all of them with very little code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DROP _:;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This is an example of using the (very handy) &lt;A href="https://go.documentation.sas.com/doc/en/lrcon/9.4/p0wphcpsfgx6o7n1sjtqzizp1n39.htm#n1dg3poi3joxh3n1tec2e293spdy" target="_self"&gt;variable name prefix list&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2024 12:07:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-does-quot-quot-in-front-of-variable-mean/m-p/943769#M369870</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2024-09-13T12:07:08Z</dc:date>
    </item>
    <item>
      <title>Re: What does "_" in front of variable mean?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-does-quot-quot-in-front-of-variable-mean/m-p/943812#M369882</link>
      <description>&lt;P&gt;Another purpose of leading underscores in variable names (not in your example) is the avoidance of name conflicts. For example, consider a SAS macro which uses a DATA step to work with a user-supplied dataset. The developer of such a macro doesn't know the user's variable names in advance. But assuming that they don't start with an underscore or even two underscores he or she might use variable names like &lt;FONT face="courier new,courier"&gt;__i&lt;/FONT&gt;&amp;nbsp;so as to make name conflicts unlikely. With the same rationale I sometimes use such names when I suggest code here in this forum.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Similarly, some SAS procedures (e.g., PROC SUMMARY and PROC TRANSPOSE) create variable names with leading and trailing underscores. And there are the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lepg/p1kfea7go1hi5qn1beilekqz6pf2.htm" target="_blank" rel="noopener"&gt;automatic variables&lt;/A&gt; _N_, _ERROR_, _IORC_, etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(Anecdote: I remember a company's standard reporting macro which surprisingly didn't work well when a user applied it to a dataset containing &lt;EM&gt;temperature&lt;/EM&gt; data in a variable TEMP. Why? The macro developer had carelessly used that same name for a variable to store some intermediate results&amp;nbsp;&lt;EM&gt;temporarily&lt;/EM&gt;.)&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2024 14:41:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-does-quot-quot-in-front-of-variable-mean/m-p/943812#M369882</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2024-09-13T14:41:54Z</dc:date>
    </item>
    <item>
      <title>Re: What does "_" in front of variable mean?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-does-quot-quot-in-front-of-variable-mean/m-p/943813#M369883</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Another purpose of leading underscores in variable names (not in your example) is the avoidance of name conflicts. For example, consider a SAS macro which uses a DATA step to work with a user-supplied dataset. The developer of such a macro doesn't know the user's variable names in advance. But assuming that they don't start with an underscore or even two underscores he or she might use variable names like &lt;FONT face="courier new,courier"&gt;__i&lt;/FONT&gt;&amp;nbsp;so as to make name conflicts unlikely. With the same rationale I sometimes use such names when I suggest code here in this forum.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Similarly, some SAS procedures (e.g., PROC SUMMARY and PROC TRANSPOSE) create variable names with leading and trailing underscores. And there are the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lepg/p1kfea7go1hi5qn1beilekqz6pf2.htm" target="_blank" rel="noopener"&gt;automatic variables&lt;/A&gt; _N_, _ERROR_, _IORC_, etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(Anecdote: I remember a company's standard reporting macro which surprisingly didn't work well when a user applied it to a dataset containing &lt;EM&gt;temperature&lt;/EM&gt; data in a variable TEMP. Why? The macro developer had carelessly used that same name for a variable to store some intermediate results&amp;nbsp;&lt;EM&gt;temporarily&lt;/EM&gt;.)&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes, I was taught to use the __ prefix for data set variable names in macros for that reason.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've seen some people take collision avoidance further by using __macroname_ as a prefix, or even generating random variable names.&amp;nbsp; I don't go that far, but I think I did once have the problem of having two different utility macros that both created a __temp variable. So that did encourage me to put little bit more entropy into my dataset variable names.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;I find it troubling when macro developers start using _ prefixes in the names of macro variables, particularly when they do that instead of defining them as %local.&amp;nbsp; It's one of the signs that trigger me to wonder whether the macro developer understands the macro language.&amp;nbsp; That would actually be a fun paper for me to try to write some time, "Things I've seen in macro code that make me doubt the entire macro (and macro author)."&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2024 15:05:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-does-quot-quot-in-front-of-variable-mean/m-p/943813#M369883</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2024-09-13T15:05:42Z</dc:date>
    </item>
    <item>
      <title>Re: What does "_" in front of variable mean?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-does-quot-quot-in-front-of-variable-mean/m-p/943819#M369885</link>
      <description>&lt;P&gt;If you really want to create data step that uses variables that will not conflict with any variables that are in the input datasets then look into using temporary arrays.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use _NUMERIC_, _CHAR_ and _CHARACTER_ as names for arrays, but they cannot be used as names for variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For an example of this in use see this macro&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/sasutils/macros/blob/master/xport2sas.sas" target="_blank"&gt;https://github.com/sasutils/macros/blob/master/xport2sas.sas&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2024 15:57:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-does-quot-quot-in-front-of-variable-mean/m-p/943819#M369885</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-09-13T15:57:07Z</dc:date>
    </item>
    <item>
      <title>Re: What does "_" in front of variable mean?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-does-quot-quot-in-front-of-variable-mean/m-p/944119#M369969</link>
      <description>&lt;P&gt;Thank you. I misunderstood that "_" in front of variable has some functionality like variable+":".&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2024 17:42:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-does-quot-quot-in-front-of-variable-mean/m-p/944119#M369969</guid>
      <dc:creator>jackblack1222</dc:creator>
      <dc:date>2024-09-16T17:42:17Z</dc:date>
    </item>
  </channel>
</rss>

