HI,
I have the following macro:
/********************************************************/
%Macro DeepLink(site);
filename source temp;
PROC HTTP
URL = &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, '<td><p>') GT 0 and scan(scan(line, 3, '>'), 1, '<')>0 THEN DO;
DIN=scan(scan(line, 3, '>'), 1, '<');
OUTPUT;
END;
RUN;
%mend;
/********************************************************/
/*The following works ok:
%DeepLink("https://www.[some confidential site].com/exceptionalfiles");
%DeepLink("https://www.[some confidential site].com/coolfiles");
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?
Thank you all in advance,
JAR
Most likely the values in your dataset do not have quotes around them the way your manual calls to the macro did.
I would use the QUOTE() function to add the quotes. I would use single quotes in case the values had anything that might look like macro triggers to the SAS macro processor. 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.
data _null_;
set Jar.TempData;
call execute(cats('%nrstr(%deeplink)(',quote(trim(WebID),"'"),')'));
run;
Use call execute():
data _null_;
set your_dataset;
call execute(cats('%nrstr(%deeplink(',site,'))');
run;
Thank you very much. However, your code generated this error:
ERROR: Physical file does not exist, /saswork/SAS_workD73D0000F7EE_odaws01-prod-sg/#LN01235.
Please help!
JAR
@JAR wrote:
Thank you very much. However, your code generated this error:
ERROR: Physical file does not exist, /saswork/SAS_workD73D0000F7EE_odaws01-prod-sg/#LN01235.
Please help!
JAR
That's most probably not the only ERROR, as I suspect that the proc http before that failed also.
Big hint: the last ERROR or WARNING message is the least, the first one the most important.
data _null_;
set Jar.TempData;
call execute(cats('%nrstr(%deeplink(',WebID,'))'));
run;
Within the macro, put double quotes round the URL:
PROC HTTP
URL = "&site"
OUT = source
METHOD = "GET";
RUN;
Most likely the values in your dataset do not have quotes around them the way your manual calls to the macro did.
I would use the QUOTE() function to add the quotes. I would use single quotes in case the values had anything that might look like macro triggers to the SAS macro processor. 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.
data _null_;
set Jar.TempData;
call execute(cats('%nrstr(%deeplink)(',quote(trim(WebID),"'"),')'));
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: