<?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: How to pass a value from dataset into a macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-pass-a-value-from-dataset-into-a-macro/m-p/560138#M156546</link>
    <description>&lt;P&gt;Most likely the values in your dataset do not have quotes around them the way your manual calls to the macro did.&lt;/P&gt;
&lt;P&gt;I would use the QUOTE() function to add the quotes.&amp;nbsp; I would use single quotes in case the values had anything that might look like macro triggers to the SAS macro processor.&amp;nbsp; Also normally I close the %NRSTR() function call at the end of the macro name instead of also wrapping it around the parameter list for the macro call.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set Jar.TempData;
  call execute(cats('%nrstr(%deeplink)(',quote(trim(WebID),"'"),')'));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 20 May 2019 13:53:56 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-05-20T13:53:56Z</dc:date>
    <item>
      <title>How to pass a value from dataset into a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-pass-a-value-from-dataset-into-a-macro/m-p/560039#M156491</link>
      <description>&lt;P&gt;HI,&lt;/P&gt;
&lt;P&gt;I have the following macro:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/********************************************************/
%Macro DeepLink(site);
filename source temp;

PROC HTTP
URL = &amp;amp;site
OUT = source
METHOD = "GET";
RUN;



DATA Jar.Dir1(DROP = line); 
LENGTH Rec $3000.;
INFILE source LENGTH = recLen LRECL = 32767;
INPUT line $VARYING32767. recLen;

IF FIND(line, '&amp;lt;td&amp;gt;&amp;lt;p&amp;gt;') GT 0 and scan(scan(line, 3, '&amp;gt;'), 1, '&amp;lt;')&amp;gt;0 THEN DO; 
DIN=scan(scan(line, 3, '&amp;gt;'), 1, '&amp;lt;');
OUTPUT;
END;
RUN;



%mend;

/********************************************************/



/*The following works ok:

%DeepLink("https://www.[some confidential site].com/exceptionalfiles");
%DeepLink("https://www.[some confidential site].com/coolfiles");&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The addresses passed are in a dataset (with only one variable and 1000 observations). Is there a way I can pass all the 1000 sites from the dataset into the macro?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you all in advance,&lt;BR /&gt;JAR&lt;/P&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2019 08:48:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-pass-a-value-from-dataset-into-a-macro/m-p/560039#M156491</guid>
      <dc:creator>JAR</dc:creator>
      <dc:date>2019-05-20T08:48:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass a value from dataset into a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-pass-a-value-from-dataset-into-a-macro/m-p/560041#M156493</link>
      <description>&lt;P&gt;Use call execute():&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set your_dataset;
call execute(cats('%nrstr(%deeplink(',site,'))');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 May 2019 08:53:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-pass-a-value-from-dataset-into-a-macro/m-p/560041#M156493</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-05-20T08:53:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass a value from dataset into a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-pass-a-value-from-dataset-into-a-macro/m-p/560112#M156534</link>
      <description>&lt;P&gt;Thank you very much. However, your code generated this error:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;ERROR: Physical file does not exist, /saswork/SAS_workD73D0000F7EE_odaws01-prod-sg/#LN01235.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Please help!&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;JAR&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2019 12:40:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-pass-a-value-from-dataset-into-a-macro/m-p/560112#M156534</guid>
      <dc:creator>JAR</dc:creator>
      <dc:date>2019-05-20T12:40:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass a value from dataset into a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-pass-a-value-from-dataset-into-a-macro/m-p/560115#M156536</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19835"&gt;@JAR&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you very much. However, your code generated this error:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;ERROR: Physical file does not exist, /saswork/SAS_workD73D0000F7EE_odaws01-prod-sg/#LN01235.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Please help!&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;JAR&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That's most probably not the only ERROR, as I suspect that the proc http before that failed also.&lt;/P&gt;
&lt;P&gt;Big hint: the last ERROR or WARNING message is the least, the first one the most important.&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2019 12:59:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-pass-a-value-from-dataset-into-a-macro/m-p/560115#M156536</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-05-20T12:59:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass a value from dataset into a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-pass-a-value-from-dataset-into-a-macro/m-p/560134#M156543</link>
      <description>&lt;DIV class="sasNote"&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set Jar.TempData;
call execute(cats('%nrstr(%deeplink(',WebID,'))'));
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="sasLogNote5_1558359677215" class="sasNote"&gt;NOTE: Line generated by the macro variable "SITE".&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;76 &lt;A href="https://www.confidential.com/AAM-6732" target="_blank"&gt;https://www.confidential.com/AAM-6732&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV class="sasError"&gt;_____&lt;/DIV&gt;
&lt;DIV class="sasError"&gt;22&lt;/DIV&gt;
&lt;DIV class="sasError"&gt;76&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="sasLogError1_1558359677215" class="sasError"&gt;ERROR 22-322: Expecting a quoted string.&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="sasLogError2_1558359677215" class="sasError"&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;BR /&gt;&lt;BR /&gt;Please help!&lt;/DIV&gt;</description>
      <pubDate>Mon, 20 May 2019 13:45:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-pass-a-value-from-dataset-into-a-macro/m-p/560134#M156543</guid>
      <dc:creator>JAR</dc:creator>
      <dc:date>2019-05-20T13:45:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass a value from dataset into a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-pass-a-value-from-dataset-into-a-macro/m-p/560137#M156545</link>
      <description>&lt;P&gt;Within the macro, put double quotes round the URL:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC HTTP
URL = "&amp;amp;site"
OUT = source
METHOD = "GET";
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 May 2019 13:49:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-pass-a-value-from-dataset-into-a-macro/m-p/560137#M156545</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-05-20T13:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass a value from dataset into a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-pass-a-value-from-dataset-into-a-macro/m-p/560138#M156546</link>
      <description>&lt;P&gt;Most likely the values in your dataset do not have quotes around them the way your manual calls to the macro did.&lt;/P&gt;
&lt;P&gt;I would use the QUOTE() function to add the quotes.&amp;nbsp; I would use single quotes in case the values had anything that might look like macro triggers to the SAS macro processor.&amp;nbsp; Also normally I close the %NRSTR() function call at the end of the macro name instead of also wrapping it around the parameter list for the macro call.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set Jar.TempData;
  call execute(cats('%nrstr(%deeplink)(',quote(trim(WebID),"'"),')'));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2019 13:53:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-pass-a-value-from-dataset-into-a-macro/m-p/560138#M156546</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-20T13:53:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass a value from dataset into a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-pass-a-value-from-dataset-into-a-macro/m-p/560149#M156549</link>
      <description>Thank you so much. Your original code, modified by Tom, is easier than this. But, it is your code Tom modified. thanks!</description>
      <pubDate>Mon, 20 May 2019 14:09:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-pass-a-value-from-dataset-into-a-macro/m-p/560149#M156549</guid>
      <dc:creator>JAR</dc:creator>
      <dc:date>2019-05-20T14:09:22Z</dc:date>
    </item>
  </channel>
</rss>

