BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
JAR
Obsidian | Level 7 JAR
Obsidian | Level 7

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

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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;

 

View solution in original post

7 REPLIES 7
JAR
Obsidian | Level 7 JAR
Obsidian | Level 7

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

Kurt_Bremser
Super User

@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.

JAR
Obsidian | Level 7 JAR
Obsidian | Level 7
data _null_;
set Jar.TempData;
call execute(cats('%nrstr(%deeplink(',WebID,'))'));
run;
 
NOTE: Line generated by the macro variable "SITE".
_____
22
76
 
 
ERROR 22-322: Expecting a quoted string.
 
ERROR 76-322: Syntax error, statement will be ignored.

Please help!
JAR
Obsidian | Level 7 JAR
Obsidian | Level 7
Thank you so much. Your original code, modified by Tom, is easier than this. But, it is your code Tom modified. thanks!
Tom
Super User Tom
Super User

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;

 

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 809 views
  • 0 likes
  • 3 in conversation