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

Hello,

 

I am using the SAS Server Path to read in a SAS dataset, and I would only like to obtain the full path of the dataset location.

 

In the return value from the SAS Server Path, it shows me the path, name and fullPath.

 

That is, when I use this code: %let file = $fileSelector.

 

This code is shown:

%let file = {path=C:\Output,
name=pq1.sas7bdat,
fullPath=C:\Output\pq1.sas7bdat};

 

I only would like to obtain the full path result, without having to subsequently use SUBSTR functions to obtain the value in fullPath. Do you know how I can achieve this please?

 

Below is some of the code that I used in my custom task:

 

<Option name="fileSelector" inputType="sasserverpath" defaultFileName="pq1"
pathType="file" defaultExtension="sas7bdat">An example of a SAS Server Path control.
This example allows the user to select a SAS program file.</Option>

 

Many thanks,

 

Kriss Harris 

1 ACCEPTED SOLUTION

Accepted Solutions
PhilC
Rhodochrosite | Level 12

I found this solution, 1) because I've wanted to learn if I could pipe a macro variable into a filename/infile statement(s) and also 2) because I've wanted to learn the input statement using the "named" input style.  I don't think this is as elegant of a solution as either of us wanted.  I defer to another for a  beautifully short answer.  I could also think of another way -- by using the SCAN function to parse the string.  

 

%let fileSelector={path=C:\Output,
name=pq1.sas7bdat,
fullPath=C:\Output\pq1.sas7bdat};

  filename in dataurl "data:&fileSelector";

data _null_;
  length fullPath $ 256;
  infile in ;
  input @;
  _infile_=compress(_infile_,"{,}");
  input fullPath=;
  call symput("fullpath",strip(fullpath));
run;

%put NOTE: fullpath=&fullpath;

View solution in original post

2 REPLIES 2
PhilC
Rhodochrosite | Level 12

I found this solution, 1) because I've wanted to learn if I could pipe a macro variable into a filename/infile statement(s) and also 2) because I've wanted to learn the input statement using the "named" input style.  I don't think this is as elegant of a solution as either of us wanted.  I defer to another for a  beautifully short answer.  I could also think of another way -- by using the SCAN function to parse the string.  

 

%let fileSelector={path=C:\Output,
name=pq1.sas7bdat,
fullPath=C:\Output\pq1.sas7bdat};

  filename in dataurl "data:&fileSelector";

data _null_;
  length fullPath $ 256;
  infile in ;
  input @;
  _infile_=compress(_infile_,"{,}");
  input fullPath=;
  call symput("fullpath",strip(fullpath));
run;

%put NOTE: fullpath=&fullpath;
djrisks
Barite | Level 11

Hi Phil,

 

Thank you for this, it's great and it works. I tested it out!

 

By the way, today I did find the elegant solution (for the velocity code).

 

 %let file = ${fileSelector.fullPath};

 Many thanks,

 

Kriss Harris

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 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 2 replies
  • 767 views
  • 2 likes
  • 2 in conversation