Desktop productivity for business analysts and programmers

Import: Prompt the user to specify the file path

Reply
Occasional Contributor
Posts: 5

Import: Prompt the user to specify the file path

[ Edited ]

Hello,

 

I searched through the internet, wherever I could find the answer. Here's my problem: I need to import a csv that is always chaging the name (isn't a piece of cake, I know Smiley Sad,  but i cannot modify this process). It is possible to prompt the user to specify the file path?

 

Any help is greatly appreciated.

Thank you.
M
Smiley Happy

Community Manager
Posts: 3,449

Re: Import: Prompt the user to specify the file path

Posted in reply to mfaqueiroz

Within EG, you could specify a project prompt (see the EG online help about "Working with prompts").  You can create a simple text prompt, or a more specific "File selection" prompt.

 

prompt.png

Super User
Super User
Posts: 9,812

Re: Import: Prompt the user to specify the file path

Posted in reply to mfaqueiroz

If you can't change the name of the file = your import documentation is broken.  How will you be versioning the file, what is the traceability.

 

Aside from that there are prompts in EG:

http://support.sas.com/resources/papers/proceedings17/0818-2017.pdf

 

But if you can't fix down the naming, can you not just save the file in one directory on its own, that way you could just use a wildcard:

data want;
  infile ".../*.csv";
...
run;

Would save some hassle.

Occasional Contributor
Posts: 5

Re: Import: Prompt the user to specify the file path

Hello,

Thank you for the answers!
I tried to do the prompt type File or directory, however  it does not access to my own pc, but rather access to the SAS Server. 
Do you know how can I do this?

 

Thanks in advance,

Mariana

 

Community Manager
Posts: 3,449

Re: Import: Prompt the user to specify the file path

Posted in reply to mfaqueiroz

You might not be able to get the "local" file dialog for that file browser.  You might need to settle for a simple text prompt (type in the value).  You can seed the value with a default that might work much of the time, depending how consistent the file locations are.

 

In order for the code that follows to be able to run, the file you select must be available to the SAS server.  So, selecting a local CSV file and then expecting a remote DATA step to process it -- that won't work.

 

If that's your situation, you can use the Data->Copy Files task (EG 7.13 and later) to copy a local file to a remote SAS and then import it. The Copy Files task accepts wildcards and macro variables, so you really can generalize it for different scenarios.  You would be doing the opposite of this: Export and download any file.

Ask a Question
Discussion stats
  • 4 replies
  • 388 views
  • 1 like
  • 3 in conversation