<?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: :INTO Variable ERROR? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/INTO-Variable-ERROR/m-p/464095#M118320</link>
    <description>&lt;P&gt;So that is one of the problems with using %EVAL(&amp;amp;mvar=) as a test for an empty macro variable.&amp;nbsp; Personally I like to use %LENGTH() to test for empty macro variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But why not just eliminate the test completely by using an iterative %DO loop instead?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%local i _meter ;
%do i=1 %to %sysfunc(countw(&amp;amp;meter));
  %let _meter=%scan(&amp;amp;meter,&amp;amp;i);
...&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 22 May 2018 15:20:47 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2018-05-22T15:20:47Z</dc:date>
    <item>
      <title>:INTO Variable ERROR?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INTO-Variable-ERROR/m-p/464064#M118301</link>
      <description>&lt;P&gt;Good morning all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm not convinced this is my issue but I'm going to start here.&amp;nbsp; I'm creating a list of variables with PROC SQL:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL NOPRINT ;
    SELECT ESIID FORMAT = $22. INTO :METER SEPARATED BY ' ' 
		FROM MINING_ESIIDS;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There's 117 observations all of which are the same length except one, the 110th OBS, it's LENGTH 22.&amp;nbsp; I have a macro that calls each :METER variable and does a MERGE and some calculations.&amp;nbsp; However, as soon as it hits the :METER with the odd length I get the following error:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: Overflow has occurred; evaluation is terminated.&lt;/P&gt;
&lt;P&gt;ERROR: The condition in the %DO %UNTIL loop, &amp;amp;_METER=, yielded an invalid or missing value, .&lt;/P&gt;
&lt;P&gt;The macro will stop executing.&lt;/P&gt;
&lt;P&gt;ERROR: The macro ESIID will stop executing.&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's the macro code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MACRO ESIID;
	%GLOBAL _METER;
    %LET I = 1;
	%LET _METER = %SCAN(&amp;amp;METER, &amp;amp;I);
	%DO %UNTIL (&amp;amp;_METER=);

DATA _NULL_;
	METER_STR = "&amp;amp;_METER";
	CALL SYMPUTX('METER_STR',"'"||METER_STR||"'");
	PUT METER_STR;
RUN;

	DATA ESIIDR_&amp;amp;_METER (KEEP = DATE1 INTERVAL ESIID2 MWH MN_COGS);
		SET INTERVAL_DATA_2;
		WHERE ESIID2 = &amp;amp;METER_STR;
		MERGE AUXCTS;
			IF ZONE = 'Houston' THEN MN_COGS = MWH * LZ_HOUSTON;
				IF ZONE = 'North' THEN MN_COGS = MWH * LZ_NORTH;
				 	IF ZONE = 'South' THEN MN_COGS = MWH * LZ_SOUTH;
					 	IF ZONE = 'West' THEN MN_COGS = MWH * LZ_WEST;
RUN;

%LET I = %EVAL(&amp;amp;I+1);
	%LET _METER = %SCAN(&amp;amp;METER, &amp;amp;I);
	%END;
	%MEND; 
%ESIID;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I exclude the odd&amp;nbsp;meter from the table the macro finishes with no errors.&amp;nbsp; I've read where I may need a Hotfix for this, but I'm reluctant to install it without trying to debug it.&amp;nbsp; Any help would be appreciated!&lt;/P&gt;</description>
      <pubDate>Tue, 22 May 2018 14:28:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INTO-Variable-ERROR/m-p/464064#M118301</guid>
      <dc:creator>BU2B</dc:creator>
      <dc:date>2018-05-22T14:28:49Z</dc:date>
    </item>
    <item>
      <title>Re: :INTO Variable ERROR? [how to improve your question]</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INTO-Variable-ERROR/m-p/464071#M118305</link>
      <description>&lt;P&gt;Hello &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/20963"&gt;@BU2B&lt;/a&gt;,&lt;/P&gt;&lt;BR /&gt; &lt;P&gt;Your question requires more details before experts can help.&amp;nbsp;Can you revise your question to include more information?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Review this checklist:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Specify a meaningful subject line for your topic.&amp;nbsp; Avoid generic subjects like "need help," "SAS query," or "urgent."&lt;/LI&gt;
&lt;LI&gt;When appropriate, provide sample data in text or DATA step format.&amp;nbsp; See &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;this article for one method&lt;/A&gt;&amp;nbsp;you can use.&lt;/LI&gt;
&lt;LI&gt;If you're encountering an error in SAS, include the SAS log or a screenshot of the error condition.&amp;nbsp;Use the&amp;nbsp;&lt;STRONG&gt;Photos&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;button to include the image in your message.&lt;BR /&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" style="width: 279px;"&gt;&lt;IMG src="https://kntur85557.i.lithium.com/t5/image/serverpage/image-id/16608i91A52F817EAC9A69/image-dimensions/279x150?v=1.0" width="279" height="150" alt="use_buttons.png" title="use_buttons.png" /&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;It also helps to include an example (table or picture) of the result that you're trying to achieve.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;To edit your original message, select the "blue gear" icon at the top of the message and select&amp;nbsp;&lt;STRONG&gt;Edit Message&lt;/STRONG&gt;.&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;From there you can adjust the title and add more details to the body of the message.&amp;nbsp; Or, simply reply to this message with any additional information you can supply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" style="width: 229px;"&gt;&lt;IMG src="https://kntur85557.i.lithium.com/t5/image/serverpage/image-id/16605iAC020BC79315B045/image-size/large?v=1.0&amp;amp;px=600" alt="edit_post.png" title="edit_post.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;SAS experts are eager to help -- help&amp;nbsp;&lt;EM&gt;them&lt;/EM&gt; by providing as much detail as you can.&lt;/P&gt; &lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-style:italic;font-size:smaller;"&gt;This prewritten response was triggered for you by fellow SAS Support Communities member &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&lt;/SPAN&gt;&lt;/P&gt;.</description>
      <pubDate>Tue, 22 May 2018 14:42:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INTO-Variable-ERROR/m-p/464071#M118305</guid>
      <dc:creator>Community_Guide</dc:creator>
      <dc:date>2018-05-22T14:42:13Z</dc:date>
    </item>
    <item>
      <title>Re: :INTO Variable ERROR?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INTO-Variable-ERROR/m-p/464073#M118306</link>
      <description>&lt;P&gt;You'll have to explain what your final DATA step is supposed to accomplish.&amp;nbsp; It's most unusual for a MERGE statement to name just a single data set, and rare for the same DATA step to contain both a SET and a MERGE statement.&lt;/P&gt;</description>
      <pubDate>Tue, 22 May 2018 14:47:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INTO-Variable-ERROR/m-p/464073#M118306</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-05-22T14:47:23Z</dc:date>
    </item>
    <item>
      <title>Re: :INTO Variable ERROR?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INTO-Variable-ERROR/m-p/464077#M118310</link>
      <description>&lt;P&gt;What is it your actually trying to do.&amp;nbsp; Start by providing some test data in the form of a datastep and what you want out at the end.&amp;nbsp; I can say quite simply that macro is not the place to be doing data processing, it is just a find/replace system, nothing more.&amp;nbsp; Creating lists of data will lead you into many difficulties.&amp;nbsp; Its very hard to help as you never provide what meter macro variable is, but at a guess I say you are trying to group out your data into several datasets based on some sort of list.&amp;nbsp; This really is not a good idea, takes more space on disk, more resources to process, and means all your code is going to be far harder to write.&amp;nbsp; What normally you would do in SAS is to apply categorisations within the dataset, i.e. a variable which can be a set via a specific set of criteria, then this categorisation variable is used in by group processing.&amp;nbsp; For instance, a very basic example, I could take all the various results in gender from sashelp.class, then write macro code to loop over each of these, or I could simply do:&lt;/P&gt;
&lt;PRE&gt;proc print data=sashelp.class;
  by gender;
  title "Group: #byval1";
run;&lt;/PRE&gt;
&lt;P&gt;So much simpler coding, no need to split out etc.&lt;/P&gt;
&lt;P&gt;Also, please avoid coding all in shouting case, it makes code far harder to read.&lt;/P&gt;</description>
      <pubDate>Tue, 22 May 2018 14:52:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INTO-Variable-ERROR/m-p/464077#M118310</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-05-22T14:52:17Z</dc:date>
    </item>
    <item>
      <title>Re: :INTO Variable ERROR?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INTO-Variable-ERROR/m-p/464080#M118311</link>
      <description>&lt;P&gt;Could you show us what the value actually is that causes the problem? Since you are not specifying a delimiter for %SCAN then any of&lt;/P&gt;
&lt;PRE&gt;ASCII:

blank ! $ % &amp;amp; ( ) * + , - . / ; &amp;lt; ^¦ 

or ~ if the ^ isn't available

EBCDIC:
blank ! $ % &amp;amp; ( ) * + , - . / ; &amp;lt; ¬ | ¢¦ &lt;/PRE&gt;
&lt;P&gt;are default delimiters. If the VALUE of your variable has any of these then the SCAN likely returned a value you don't expect. I would suspect the most likely candidate would be the dash, - , character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I will say that a number of hard to trace errors comes from actually placing quotes into macro variables.&lt;/P&gt;
&lt;P&gt;You could replace&lt;/P&gt;
&lt;PRE&gt;DATA _NULL_;
	METER_STR = "&amp;amp;_METER";
	CALL SYMPUTX('METER_STR',"'"||METER_STR||"'");
	PUT METER_STR;
RUN;
&lt;/PRE&gt;
&lt;P&gt;with&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let meter_str=%quote(&amp;amp;_meter.);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or skip placing quotes in the macro variable at all an use&lt;/P&gt;
&lt;PRE&gt;WHERE ESIID2 = "&amp;amp;_METER"
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have you run the macro with the options MPRINT and SYMBOLGEN to see what is generated?&lt;/P&gt;</description>
      <pubDate>Tue, 22 May 2018 14:53:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INTO-Variable-ERROR/m-p/464080#M118311</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-05-22T14:53:25Z</dc:date>
    </item>
    <item>
      <title>Re: :INTO Variable ERROR?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INTO-Variable-ERROR/m-p/464081#M118312</link>
      <description>&lt;P&gt;The dataset INTERVAL_DATA_2 has approximately 2,000 15 minute values for each of the 117 meters.&amp;nbsp; The MERGE dataset AUXCTS has a price for each 15 minute interval.&amp;nbsp; The macro is&amp;nbsp;creating a dataset for each :METER from INTERVAL_DATA_2 and calculating a COGS with the price from AUXCTS.&amp;nbsp; Hope this helps.&amp;nbsp; If you need more info let me know.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Steve&lt;/P&gt;</description>
      <pubDate>Tue, 22 May 2018 14:55:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INTO-Variable-ERROR/m-p/464081#M118312</guid>
      <dc:creator>BU2B</dc:creator>
      <dc:date>2018-05-22T14:55:02Z</dc:date>
    </item>
    <item>
      <title>Re: :INTO Variable ERROR?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INTO-Variable-ERROR/m-p/464087#M118314</link>
      <description>&lt;P&gt;Really big numbers can cause overflows like that.&amp;nbsp; I could replicate your error with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%MACRO ESIID;
  %GLOBAL _METER;
  %LET I = 1;
  %LET _METER = %SCAN(&amp;amp;METER, &amp;amp;I);
  %DO %UNTIL (&amp;amp;_METER=);
    %put &amp;amp;=_METER ;
    %LET I = %EVAL(&amp;amp;I+1);
    %LET _METER = %SCAN(&amp;amp;METER, &amp;amp;I);
  %END ;
%MEND ;

%let meter=1 2 1234567890123456789012 ;
%ESIID ;&lt;/PRE&gt;
&lt;P&gt;Your %DO UNTIL sees that really big number and chokes.&amp;nbsp; One hack to avoid this problem is to add a character to the comparison, so that %DO UNTIL will see a text string, rather than a number.&amp;nbsp; Since all your checking for is a null value, I would think this would this work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below I add a Z to the string:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%DO %UNTIL (Z&amp;amp;_METER=Z);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Generally it's a good idea to declare macro variables created inside a macro as local macro variables, and to pass variables to macros as parameters rather than rely on global macro variables. But those are separate issues.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 May 2018 15:06:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INTO-Variable-ERROR/m-p/464087#M118314</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2018-05-22T15:06:06Z</dc:date>
    </item>
    <item>
      <title>Re: :INTO Variable ERROR?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INTO-Variable-ERROR/m-p/464089#M118315</link>
      <description>&lt;P&gt;Here's a snipet from the values in the variable :METER.&amp;nbsp; As soon as the macro hits the odd length record it crashes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 156px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/20693iB8F00FA6BA56C67F/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 May 2018 15:06:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INTO-Variable-ERROR/m-p/464089#M118315</guid>
      <dc:creator>BU2B</dc:creator>
      <dc:date>2018-05-22T15:06:53Z</dc:date>
    </item>
    <item>
      <title>Re: :INTO Variable ERROR?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INTO-Variable-ERROR/m-p/464091#M118317</link>
      <description>&lt;P&gt;Thanks so much Quentin!&amp;nbsp; I've spent hours trying to figure this out...&lt;/P&gt;</description>
      <pubDate>Tue, 22 May 2018 15:10:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INTO-Variable-ERROR/m-p/464091#M118317</guid>
      <dc:creator>BU2B</dc:creator>
      <dc:date>2018-05-22T15:10:51Z</dc:date>
    </item>
    <item>
      <title>Re: :INTO Variable ERROR?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INTO-Variable-ERROR/m-p/464095#M118320</link>
      <description>&lt;P&gt;So that is one of the problems with using %EVAL(&amp;amp;mvar=) as a test for an empty macro variable.&amp;nbsp; Personally I like to use %LENGTH() to test for empty macro variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But why not just eliminate the test completely by using an iterative %DO loop instead?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%local i _meter ;
%do i=1 %to %sysfunc(countw(&amp;amp;meter));
  %let _meter=%scan(&amp;amp;meter,&amp;amp;i);
...&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 May 2018 15:20:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INTO-Variable-ERROR/m-p/464095#M118320</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-05-22T15:20:47Z</dc:date>
    </item>
    <item>
      <title>Re: :INTO Variable ERROR?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INTO-Variable-ERROR/m-p/464100#M118323</link>
      <description>&lt;P&gt;Thanks for the tip Tom.&amp;nbsp; I will give that a&amp;nbsp;try and get back to you.&amp;nbsp; I'm always looking for more elegant ways to write code.&amp;nbsp; Mine's kind of sloppy..&amp;nbsp; &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 22 May 2018 15:25:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INTO-Variable-ERROR/m-p/464100#M118323</guid>
      <dc:creator>BU2B</dc:creator>
      <dc:date>2018-05-22T15:25:26Z</dc:date>
    </item>
    <item>
      <title>Re: :INTO Variable ERROR?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INTO-Variable-ERROR/m-p/464290#M118363</link>
      <description>&lt;PRE&gt;proc sort data=meter out=loop nodupkey;
  by meter;
run;
data _null_;
  set loop;
  call execute(cats('data meter_',meter,'; set meter; where meter="',meter,'"; run;'));
run;&lt;/PRE&gt;
&lt;P&gt;No loops, no macro code, no restrictions on number of elements etc.&amp;nbsp; Although as before, splitting data up into smaller datasets is not a good idea from storage or coding point of view.&lt;/P&gt;</description>
      <pubDate>Wed, 23 May 2018 06:42:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INTO-Variable-ERROR/m-p/464290#M118363</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-05-23T06:42:20Z</dc:date>
    </item>
  </channel>
</rss>

