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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Develop Code with SAS Studio

Get started using SAS Studio to write, run and debug your SAS programs.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1172 views
  • 2 likes
  • 2 in conversation