BookmarkSubscribeRSS Feed
annypanny
Quartz | Level 8

Hi community,

I am using this code to

find out today's file and read that file into a dataset:

data _null_;
length dsnname $100;
today=put(today(),yymmdd7.);
dsnname = compress('c:\temp\'||today||'.txt');
file phold filevar=dsnname notitles;
put today;
run;

 

but getting this error: Insufficient authorization to access /sas/config/Lev1/SASApp/c:\temp\200416.txt

how to  solve this I also want to add

'/folders/myfolders/sales.pdf'

but don't know where to add this.

my file format is OnlineUser20200416 but in the error it is showing 200416, please correct the date time format in this code too. I am using windows(EG sas)

Thanks in advance

Edited

9 REPLIES 9
yabwon
Amethyst | Level 16
Hi,

From your error it look that you try to write a Windows machine file "c:\temp\20200416.txt" from the linux/UNIX machine (/sas/config/Lev1/SASApp/).
I'm guessing that your filename statement is:
`filename PHOLD "c:\temp\20200416.txt";` ?
You have to create file on the Linux/UNIX machine first (e.g. in your home folder `filename PHOLD "~/20200416.txt";`). and then copy it to WIndows.

All the best
Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



annypanny
Quartz | Level 8
could you please give the soluion that what change I have to do in my code and where, as I am a bit confuse here
yabwon
Amethyst | Level 16

Ok, so step by step:

 

1) Just to clarify, you are working on Linux/UNIX server, right?

2) you have a data set on your windows PC in folder: "c:\temp\" and the filename is "OnlineUser20200416.txt"

3) you want to read the file into a SAS dataset (if yes, what is the file structure)?

 

Bart

 

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



Kurt_Bremser
Super User

@annypanny wrote:
1. i am working on windows system.
3.yes

If you can show me a path like

/sas/config/Lev1/SASApp/

on any Windows system in production use, I will happily eat that broomstick over there (in German: "dann fress' ich einen Besen").

Your Enterprise Guide (or the browser with which you access SAS Studio) runs on Windows, but your SAS runs on a UNIX system.

yabwon
Amethyst | Level 16

Hi,

 

I'm confused by your answers.

I see two options: either you elaborate about your issue in clearer way, or I won't be able to help you.

 

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



annypanny
Quartz | Level 8
I have successfully run the above code now how can I read the dataset?
using infile?
Kurt_Bremser
Super User

Since this is a continuation from https://communities.sas.com/t5/SAS-Programming/How-to-extract-an-external-file-into-a-sas-dataset-in..., I quote my answers from there:

 

You must always keep in mind that you work in a client/server environment. Code you run on the server (via SAS Studio or Enterprise Guide) has to use path names available on the server, and the syntax of the server's operating system.

Since your SAS server is obviously a UNIX system, you need to use the UNIX File System language. And point your file references to locations where you have the required permissions.

and

 

I cannot look into your server (if I could, I would either have the police knocking soon, or your IT people would all be fired), so you need to know where to put data in your system environment. Get help from your server administrators, they can tell you where to put data on the server (a good bet is always $HOME), and how to move the data from there to its final intended location.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 9 replies
  • 12711 views
  • 2 likes
  • 3 in conversation