DATA Step, Macro, Functions and more

How to export sas table to txt file

Reply
Contributor
Posts: 34

How to export sas table to txt file

Hello,

 

I am trying to export the sas table to text file. Running this code;

 

DATA _NULL_;

SET Final_Out;

FILE "C:\SDB\ADMISStest\TEST.txt"

LRECL=250 ;

PUT @1 E1010 $7. @8 E1012 $10. @18 E1013 $3. @21 E1014 $10.

@31 E101A $1. @32 E1008 $20. ;

run;

 

 

I created 'test' table in the area I want. And I have access that area.

But I have this error when I run this code;

 

ERROR: Insufficient authorization to access /app/config/Lev1/SASApp/C:\SDB\ADMISStest\TEST.txt.

 

Thank you,

 

 

 

 

Super Contributor
Posts: 500

Re: How to export sas table to txt file

So SAS is running on a (L)unix system. You can't access your local drives, you have to use a directory on the server, asking your local sas.-admins will most likely reveal an appropriate directory.

Super Contributor
Posts: 472

Re: How to export sas table to txt file

Hi @user24,

 

Give some more details on your environment. Seems like your SAS is running on UNIX/LINUX and your trying to send a file to your local drive. This is not possible because SAS doesn't know your area as it is running on a server some where else. Ask your admin if they have mapped a NAS drive in SAS, that can be mapped as network drive in your local machine and can be used to transfer files from NAS to Local.

 

Another alternate way is send files to your SAS server and then use WinSCP to transfer those files from server to local machine.

Thanks,
Suryakiran
Super Contributor
Posts: 320

Re: How to export sas table to txt file

Hello,

If you're using SEG, right click in the program editor lets you select whicjh server to run the program on. There must be a  "Select server" entry in the contextual menu  (my SEG version is in french so the exact label may differ) where you can select "local".

Super User
Posts: 9,604

Re: How to export sas table to txt file

The problem with that apporoach is that the local session won't see the server tables that need to be exported.

 

Either a shared resource or a utility like WinSCP to copy the resulting text file is needed.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Super User
Posts: 13,066

Re: How to export sas table to txt file


@user24 wrote:

Hello,

 

I am trying to export the sas table to text file. Running this code;

 

DATA _NULL_;

SET Final_Out;

FILE "C:\SDB\ADMISStest\TEST.txt"

LRECL=250 ;

PUT @1 E1010 $7. @8 E1012 $10. @18 E1013 $3. @21 E1014 $10.

@31 E101A $1. @32 E1008 $20. ;

run;

 

 

I created 'test' table in the area I want. And I have access that area.

But I have this error when I run this code;

 

ERROR: Insufficient authorization to access /app/config/Lev1/SASApp/C:\SDB\ADMISStest\TEST.txt.

 

Thank you,

 

 

 

 


A very minor secondary consideration is that you do not need to create the output text file first. The code with a file statement as you are using it will create a file or replace an existing file without the use of the MOD option to modify an existing file.

Ask a Question
Discussion stats
  • 5 replies
  • 95 views
  • 1 like
  • 6 in conversation