<?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: SAS Macro : Variable name passed instead of Variable's value when using Macro ... in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Variable-name-passed-instead-of-Variable-s-value-when/m-p/707487#M217223</link>
    <description>&lt;P&gt;I don't get how macro code is going to help you here.&amp;nbsp; What part of the code do you want to use the macro variable to generate?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You seem to be saying that the upper bound for CNT needs to be dynamic in some way, but your current code is already dynamic.&amp;nbsp; It is referencing a variable RDE_LEN that can have a different value on each observation read from the&amp;nbsp;&lt;SPAN&gt;QUERY001 dataset.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Do you need join two tables to get the right values of RDE_LEN attached to the right observations in QUERY001?&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 21 Dec 2020 14:52:12 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2020-12-21T14:52:12Z</dc:date>
    <item>
      <title>SAS Macro : Variable name passed instead of Variable's value when using Macro ...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Variable-name-passed-instead-of-Variable-s-value-when/m-p/707404#M217191</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Firstly, am using SAS (ver - 9.4) on Mainframes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Secondly on the issue, I used Proc SQL to get some data from a Mainframe Dataset, then used a SET statement to filter some criteria. Now that being done, I have 2 variables (RDE_LEN &amp;amp; RDE_ALL). RDE is just a segment in simple terms and RDE_LEN has the whole length of the RDE_ALL (which has multiple segments like N1, N2 etc with different lengths).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used the traditional SAS code to break the segments and get the values as needed. Now I am trying to do it via a Macro as this segment break happens at multiple places of the program.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So when I try to pass the RDE length value, say 3000 bytes, am getting the Variable name i.e. RDE_LEN instead of 3000.&lt;/P&gt;&lt;P&gt;Not sure where I made the mistake (plus I am new to Macros).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have attached the all the code snippets below , pls have a look and advise. Also if you need more info, please revert, will provide them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Mohan&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Code snippets:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Current working SAS code without Macro:&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;DATA BASE001; &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;SET QUERY001; &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;WHERE SUBSTR(INTMSGID,1,3) IN ('A01', 'A02', 'A04'); &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;CNT = 1; &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;DO UNTIL(CNT &amp;gt;= RDE_LEN); &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;SEG_HEX = PUT(SUBSTR(RDE_ALL,CNT,2),HEX4.); &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;SEG_LEN = INPUT(SEG_HEX,HEX4.); &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;SEG_RDE = SUBSTR(RDE_ALL,CNT,SEG_LEN); &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;SEG_NAM = SUBSTR(SEG_RDE,3,2); &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;CNT = CNT + 2 + SEG_LEN; &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;SELECT; &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;WHEN (SEG_NAM = 'N1') DO; &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;N1_FBK = SUBSTR(SEG_RDE,007,004); &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;N1_DCCI = SUBSTR(SEG_RDE,011,001); &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;N1_EMVPOS = PUT(SUBSTR(SEG_RDE,012,001),HEX2.); &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;N1_EMVEXP = SUBSTR(SEG_RDE,013,006); &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;N1_BMAPS = PUT(SUBSTR(SEG_RDE,021,003),HEX6.); &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;N1_FCR = SUBSTR(SEG_RDE,024,001); &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;END; &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;OTHERWISE; &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;END; &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;END; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Macro definition:&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;********************************* Top of Data **********************************&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;options symbolgen mprint mlogic; &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;%macro _brk_seg(lngth); &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;%put &amp;amp;lngth; &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;%mend _brk_seg; &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;******************************** Bottom of Data ********************************&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Macro Invocation:&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;DATA BASE001; &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;SET QUERY001; &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;WHERE SUBSTR(INTMSGID,1,3) IN ('A01', 'A02', 'A04'); &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;%_brk_seg(RDE_LEN); &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;RUN; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;MLOGIC Output:&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;MLOGIC(_BRK_SEG): Beginning execution. &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;MLOGIC(_BRK_SEG): Parameter LNGTH has value RDE_LEN &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;MLOGIC(_BRK_SEG): %PUT &amp;amp;lngth &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;SYMBOLGEN: Macro variable LNGTH resolves to RDE_LEN &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;RDE_LEN &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;MLOGIC(_BRK_SEG): Ending execution. &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2020 11:04:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Variable-name-passed-instead-of-Variable-s-value-when/m-p/707404#M217191</guid>
      <dc:creator>Mohan03</dc:creator>
      <dc:date>2020-12-21T11:04:00Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macro : Variable name passed instead of Variable's value when using Macro ...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Variable-name-passed-instead-of-Variable-s-value-when/m-p/707413#M217195</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%_brk_seg(RDE_LEN);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You are assigning a text string to the macro argument &amp;amp;LNGTH. That text string is 7 characters long, and is these 7 characters: RDE_LEN&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS doesn't know you have other meaning intended for this text string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps (it's not really clear to me) you mean&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let rde_len=3000;


DATA BASE001;
SET QUERY001;
WHERE SUBSTR(INTMSGID,1,3) IN ('A01', 'A02', 'A04');
%_brk_seg(&amp;amp;rde_len)
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2020 12:06:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Variable-name-passed-instead-of-Variable-s-value-when/m-p/707413#M217195</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-12-21T12:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macro : Variable name passed instead of Variable's value when using Macro ...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Variable-name-passed-instead-of-Variable-s-value-when/m-p/707436#M217204</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Thanks for that, let me try to explain my best again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ok, l tweaked a bit (added a Proc SQL statement) in the Macro invocation section and got the RDE_LEN value into a host variable (snippet below) and then invoked the Macro from there and it got me the result as expected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I am trying to achieve this by avoiding an extra Proc SQL step, i.e. in the Data step (DATA BASE001) itself which would help in performance as the dataset is huge.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Macro Invocation:&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;DATA BASE001;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;SET QUERY001;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;WHERE SUBSTR(INTMSGID,1,3) IN ('A01', 'A02', 'A04');&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;STRIKE&gt;&lt;FONT face="courier new,courier"&gt;%_brk_seg(RDE_LEN);&lt;/FONT&gt;&lt;/STRIKE&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;RUN;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;called the below after the Proc SQL:&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;PROC SQL; &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;SELECT RDE_LEN &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;INTO &lt;STRONG&gt;:WS_LEN &lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;FROM BASE001 &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;QUIT; &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;%_brk_seg(&lt;STRONG&gt;&amp;amp;WS_LEN&lt;/STRONG&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;MLOGIC excerpt:&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;MLOGIC(_BRK_SEG): Beginning execution. &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;SYMBOLGEN: Macro variable WS_LEN resolves to 433 &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;MLOGIC(_BRK_SEG): Parameter LNGTH has value 433 &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;MLOGIC(_BRK_SEG): %PUT &amp;amp;lngth &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;SYMBOLGEN: Macro variable LNGTH resolves to 433 &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;433 &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;MLOGIC(_BRK_SEG): Ending execution. &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Mohan.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2020 13:17:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Variable-name-passed-instead-of-Variable-s-value-when/m-p/707436#M217204</guid>
      <dc:creator>Mohan03</dc:creator>
      <dc:date>2020-12-21T13:17:34Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macro : Variable name passed instead of Variable's value when using Macro ...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Variable-name-passed-instead-of-Variable-s-value-when/m-p/707440#M217205</link>
      <description>&lt;P&gt;I do not understand the relationship between your DATA step and your PROC SQL.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2020 13:21:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Variable-name-passed-instead-of-Variable-s-value-when/m-p/707440#M217205</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-12-21T13:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macro : Variable name passed instead of Variable's value when using Macro ...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Variable-name-passed-instead-of-Variable-s-value-when/m-p/707444#M217207</link>
      <description>&lt;P&gt;Learning macros forces us to learn more about how SAS (and other programming languages) process these different types of variables.&amp;nbsp; First when SAS runs your code it runs in phases.&amp;nbsp; Long story short, there's a "macro preprocessor" phase (see note) where the macro variables and macro functions are defined and applied to the code.&amp;nbsp; In later phases, the "compile and execution" phases, the data steps and procedures are compiled and then ran.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When the macro function you created runs, it "SAS" can't know that RDE_LEN is a variable in the data step, nor can it know any of its future values.&amp;nbsp; SAS only knows that&amp;nbsp;RDE_LEN is a variable in the data step during the compile phase, where, then, it assigns 3000 to the RDE_LEN.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;wrote is true, I think I'm filling in some of the holes in the story.&amp;nbsp; We try to explain things as simply as we need to.&amp;nbsp; I hope I hit that target with this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;note&lt;/STRONG&gt;:&amp;nbsp;excuse me, there might be another term for the "macro preprocessor" phase.&amp;nbsp; I have searched but I can't find where I learned this.&amp;nbsp; I think I remember seeing a SAS tutorial explaining it, but then I could have seen the same in a C programming class in college.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2020 14:09:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Variable-name-passed-instead-of-Variable-s-value-when/m-p/707444#M217207</guid>
      <dc:creator>PhilC</dc:creator>
      <dc:date>2020-12-21T14:09:52Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macro : Variable name passed instead of Variable's value when using Macro ...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Variable-name-passed-instead-of-Variable-s-value-when/m-p/707451#M217213</link>
      <description>&lt;P&gt;The DATA step has a subset of rows from a huge file with around 100 columns (Input variables) and the RDE_LEN is one of it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;something like this:&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;DATA TODAY; &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;INPUT ID RDE_LEN RDE_ALL;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;CARDS; &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;0001 433 N1_seg+N1_data_of_433_bytes&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;0001 900 N2_seg+N2_data_of_900_bytes&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;0001 099 N3_seg+N3_data_of_099_bytes etc&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I need the value of RDE_LEN (i.e. 433 in the first instance) and pass it to a Macro to do some process. When I try to do it without the Proc SQL, I was getting the variable name RDE_LEN instead of its value 433.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But when I used Proc SQL, am getting the value of 433. So other than this, there is no relation between DATA step and Proc SQL.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope its clear and the question is, can these values be gotten from the DATA step instead of additional Proc SQL ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Mohan&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2020 13:47:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Variable-name-passed-instead-of-Variable-s-value-when/m-p/707451#M217213</guid>
      <dc:creator>Mohan03</dc:creator>
      <dc:date>2020-12-21T13:47:56Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macro : Variable name passed instead of Variable's value when using Macro ...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Variable-name-passed-instead-of-Variable-s-value-when/m-p/707453#M217214</link>
      <description>&lt;P&gt;Given the data set you show, do you want to do this three times? Once when RDE_LEN is 433, and once when RDE_LEN is 900, and once when RDE_LEN is 099? (And if the data set has four or more rows, whould you want to do it once for each row?)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then what? Suppose you have now a macro variables that has value 433, do you then run a macro with that value? And then run it again when the macro variable has value 900? And so on?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Really, the whole process isn't clear to me, and we see the trees, but we don't see the forest.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm going to take a step back here, and insist that you show us the desired code,&amp;nbsp;&lt;EM&gt;without macros and without macro variables&lt;/EM&gt;,&amp;nbsp;for two cases, one when RDE_LEN in 433 and one when RDE_LEN is 900. That's the best way to move forward, and really, its the best way to develop macros by starting from working code that doesn't have macros and doesn't have macro variables.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2020 14:00:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Variable-name-passed-instead-of-Variable-s-value-when/m-p/707453#M217214</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-12-21T14:00:34Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macro : Variable name passed instead of Variable's value when using Macro ...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Variable-name-passed-instead-of-Variable-s-value-when/m-p/707462#M217219</link>
      <description>&lt;P&gt;That is correct.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For every row, the length of the segment is taken and passed to the Macro where it will break down the data part of the segment into its own smaller fields, like below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;WHEN (SEG_NAM = 'N1') DO;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;N1_FBK = SUBSTR(SEG_RDE,007,004);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;N1_DCCI = SUBSTR(SEG_RDE,011,001);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;N1_EMVPOS = PUT(SUBSTR(SEG_RDE,012,001),HEX2.);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;N1_EMVEXP = SUBSTR(SEG_RDE,013,006);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;N1_BMAPS = PUT(SUBSTR(SEG_RDE,021,003),HEX6.);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;N1_FCR = SUBSTR(SEG_RDE,024,001);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;END;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;OTHERWISE;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;END;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That part, I can get the count of the records and iterate through the rest of the rows (if the first row is processed successfully). But was struck in the very first row while passing the value to Macro, so to keep it simple, didn't mention the iteration part.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Mohan&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2020 14:11:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Variable-name-passed-instead-of-Variable-s-value-when/m-p/707462#M217219</guid>
      <dc:creator>Mohan03</dc:creator>
      <dc:date>2020-12-21T14:11:58Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macro : Variable name passed instead of Variable's value when using Macro ...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Variable-name-passed-instead-of-Variable-s-value-when/m-p/707477#M217221</link>
      <description>&lt;P&gt;Below is the current working SAS code without Macro (highlighted in &lt;FONT color="#0000FF"&gt;blue&lt;/FONT&gt;) and it works as expected. And since the RDE needs to be broken down at multiple segments, currently am using the "without Macros" SAS code. So want to make the blue piece a Macro defined first and where needed, I can just pass the RDE_LEN &amp;amp; RDE_ALL (data part) and break them into smaller units and get them for report.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;DATA BASE001;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;SET QUERY001;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;WHERE SUBSTR(INTMSGID,1,3) IN ('A01', 'A02', 'A04');&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#0000FF"&gt;CNT = 1;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#0000FF"&gt;DO UNTIL(CNT &amp;gt;= RDE_LEN);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#0000FF"&gt;SEG_HEX = PUT(SUBSTR(RDE_ALL,CNT,2),HEX4.);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#0000FF"&gt;SEG_LEN = INPUT(SEG_HEX,HEX4.);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#0000FF"&gt;SEG_RDE = SUBSTR(RDE_ALL,CNT,SEG_LEN);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#0000FF"&gt;SEG_NAM = SUBSTR(SEG_RDE,3,2);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#0000FF"&gt;CNT = CNT + 2 + SEG_LEN;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#0000FF"&gt;SELECT;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#0000FF"&gt;WHEN (SEG_NAM = 'N1') DO;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#0000FF"&gt;N1_FBK = SUBSTR(SEG_RDE,007,004);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#0000FF"&gt;N1_DCCI = SUBSTR(SEG_RDE,011,001);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#0000FF"&gt;N1_EMVPOS = PUT(SUBSTR(SEG_RDE,012,001),HEX2.);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#0000FF"&gt;N1_EMVEXP = SUBSTR(SEG_RDE,013,006);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#0000FF"&gt;N1_BMAPS = PUT(SUBSTR(SEG_RDE,021,003),HEX6.);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#0000FF"&gt;N1_FCR = SUBSTR(SEG_RDE,024,001);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#0000FF"&gt;END;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#0000FF"&gt;OTHERWISE;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#0000FF"&gt;END;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#0000FF"&gt;END;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" color="#000000"&gt;Below is the SAS code with Macro (not a working one though):&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;%MACRO _FMTRDE(LNGTH,DATA);&lt;BR /&gt;%LET CNT = 1;&lt;BR /&gt;DO UNTIL(&amp;amp;CNT &amp;gt;= &amp;amp;LNGTH);&lt;BR /&gt;%LET SEG_HEX = PUT(SUBSTR(&amp;amp;DATA,&amp;amp;CNT,2),HEX4.);&lt;BR /&gt;%LET SEG_LEN = INPUT(&amp;amp;SEG_HEX,HEX4.);&lt;BR /&gt;%LET SEG_RDE = SUBSTR(&amp;amp;DATA,&amp;amp;CNT,&amp;amp;SEG_LEN);&lt;BR /&gt;%LET SEG_NAM = SUBSTR(&amp;amp;SEG_RDE,3,2);&lt;BR /&gt;%LET CNT = %EVAL(&amp;amp;CNT + 2 + %SEG_LEN);&lt;BR /&gt;%PUT &amp;amp;SEG_NAM; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" color="#008000"&gt;.... Substrings to break further&lt;BR /&gt;END;&lt;BR /&gt;%MEND _FMTRDE; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2020 14:30:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Variable-name-passed-instead-of-Variable-s-value-when/m-p/707477#M217221</guid>
      <dc:creator>Mohan03</dc:creator>
      <dc:date>2020-12-21T14:30:27Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macro : Variable name passed instead of Variable's value when using Macro ...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Variable-name-passed-instead-of-Variable-s-value-when/m-p/707487#M217223</link>
      <description>&lt;P&gt;I don't get how macro code is going to help you here.&amp;nbsp; What part of the code do you want to use the macro variable to generate?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You seem to be saying that the upper bound for CNT needs to be dynamic in some way, but your current code is already dynamic.&amp;nbsp; It is referencing a variable RDE_LEN that can have a different value on each observation read from the&amp;nbsp;&lt;SPAN&gt;QUERY001 dataset.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Do you need join two tables to get the right values of RDE_LEN attached to the right observations in QUERY001?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2020 14:52:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Variable-name-passed-instead-of-Variable-s-value-when/m-p/707487#M217223</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-12-21T14:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macro : Variable name passed instead of Variable's value when using Macro ...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Variable-name-passed-instead-of-Variable-s-value-when/m-p/707494#M217225</link>
      <description>&lt;P&gt;So, earlier you posted a data step that creates a data set named TODAY, containing values for RDE_LEN.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Then you want to use these values in the code you just presented that creates data set BASE001, sequentially, so the first time you execute the code to create BASE001 you use RDE_LEN = 433. Then you create BASE001 (or perhaps it has a different name?) with RDE_LEN=900, and so on? Is that it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The overall method is described here:&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Run-macro-for-values-in-data-set/m-p/707193#M217118" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Run-macro-for-values-in-data-set/m-p/707193#M217118&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think your macro has to contain the DATA statement and an entire data step, beginning with&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro dothis(rde_len);
DATA BASE001;
    SET QUERY001;
    WHERE SUBSTR(INTMSGID,1,3) IN ('A01', 'A02', 'A04');
    CNT = 1;
    DO UNTIL(CNT &amp;gt;=  &amp;amp;RDE_LEN);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and obviously there's more to that DATA step. And you probably also want the data set created the second time to be named BASE002, and so on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But really, I still don't think I have the right understanding of your task, and it might be worthwhile for you to take a step back, and re-write the whole thing from the beginning, to generate a complete and clear problem statement, as if you are about to present this to a college professor who is going to grade you.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2020 14:59:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Variable-name-passed-instead-of-Variable-s-value-when/m-p/707494#M217225</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-12-21T14:59:36Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macro : Variable name passed instead of Variable's value when using Macro ...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Variable-name-passed-instead-of-Variable-s-value-when/m-p/707498#M217228</link>
      <description>&lt;P&gt;Ah no, nothing to do with the join to manipulate the RDE_LEN.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As I mentioned, am new to the Macros in SAS. So just trying to work out the redundancy of the same executable codes in different places using Macros (seems am looking in for UDF but ended up with Macros).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your comment.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2020 15:12:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Variable-name-passed-instead-of-Variable-s-value-when/m-p/707498#M217228</guid>
      <dc:creator>Mohan03</dc:creator>
      <dc:date>2020-12-21T15:12:55Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macro : Variable name passed instead of Variable's value when using Macro ...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Variable-name-passed-instead-of-Variable-s-value-when/m-p/707501#M217230</link>
      <description>&lt;P&gt;Think I got what I needed from this discussion with you experts.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Will take your valuable inputs from here, try and work out out my best on my requirements. Will seek your advise via another thread for any other expert inputs (probably may come back for the some tuning recommendations).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15329"&gt;@PhilC&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp; for your time and expertise. Really appreciate your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Oops ! Not sure how to close this discussion (if I can), so just leaving (or advise me how, will action on it).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Mohan&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2020 15:28:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Variable-name-passed-instead-of-Variable-s-value-when/m-p/707501#M217230</guid>
      <dc:creator>Mohan03</dc:creator>
      <dc:date>2020-12-21T15:28:19Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macro : Variable name passed instead of Variable's value when using Macro ...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Variable-name-passed-instead-of-Variable-s-value-when/m-p/707512#M217236</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/361524"&gt;@Mohan03&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Think I got what I needed from this discussion with you experts.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Will take your valuable inputs from here, try and work out out my best on my requirements. Will seek your advise via another thread for any other expert inputs (probably may come back for the some tuning recommendations).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15329"&gt;@PhilC&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp; for your time and expertise. Really appreciate your help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Oops ! Not sure how to close this discussion (if I can), so just leaving (or advise me how, will action on it).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Mohan&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That's good to know. There is no need to "close" the discussion, it stays open in case others want to contribute.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2020 15:52:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Variable-name-passed-instead-of-Variable-s-value-when/m-p/707512#M217236</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-12-21T15:52:44Z</dc:date>
    </item>
  </channel>
</rss>

