Learning SAS? Welcome to the exclusive online community for all SAS learners.

Filename pipe to load data in SAS UE

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 91
Accepted Solution

Filename pipe to load data in SAS UE

I am trying to load files into a directory using SAS UE using the following commands:

/*create library to HOLD THE FILES*/
LIBNAME ALL '/folders/myfolders/FOCALIN_QUAL_SAS/0BOOT/QUAL_GRAPHS2/'

 

I read in the files :

/*READ THE FILES IN AND STORE THEM IN A SEPERATE FOLDER*/
%MACRO NEW1;
%do i=1% to 200;
DATA  ALL.a&i;
INFILE "/folders/myfolders/FOCALIN_QUAL_SAS/MEDVALGRAPHS/MEDGRSIM&i..CSV" FIRSTOBS=2 DLM=',';
/*INFILE "C:\Data\CONCERTA_2012\ANDA202731_FOCALIN\INDIVFITS\REFS\0BOOT\MEDVALGRAPHS\MEDGRSIM&i..CSV" FIRSTOBS=2 DLM=',';*/
input  TIME   REP   NOBS   y_MEDIAN&i ;
drop rep nobs;
/**********************************************/;

%END;
%mend NEW1;
%NEW1;
run;

 

Finally I used the pipe command to read the files into the directory Qual_graphs2

filename indata pipe 'DIR /folders/myfolders/FOCALIN_QUAL_SAS/0BOOT/QUAL_GRAPHS2/b';

 

I get this error:

ERROR: Insufficient authorization to access PIPE.
ERROR: Error in the FILENAME statement.
 
I looked at a couple of post online related to this subject but I couldn't seem to resolve my issue.
Can someone take a look  at this issue and give me a suggestion how best to resolve?  I have attached one of the files I am trying to transfer medgrsim1.

Accepted Solutions
Solution
‎08-14-2017 01:46 PM
Super User
Posts: 18,603

Re: Filename pipe to load data in SAS UE

@jacksonan123 The appendix has a sample macro that lists all file that doesn't use PIPE commands, I think this one does work on SAS UE, but haven't tested it. It does note that it doesn't work in a Locked down state and SAS UE may be locked down.

 

http://support.sas.com/documentation/cdl/en/mcrolref/69726/HTML/default/viewer.htm#n0js70lrkxo6uvn1f...

 

View solution in original post


All Replies
Super User
Posts: 18,603

Re: Filename pipe to load data in SAS UE

I don't think SAS UE supports pipe commands. Are you trying to find a list of files? If so, check the macro appendix. 

Frequent Contributor
Posts: 91

Re: Filename pipe to load data in SAS UE

i am trying to load files for later use.   Once I check the macro appendix what info  will that give me?

 

Are there alternatives to pipe commands in SAS UE?

 

Thanks

Super User
Posts: 5,323

Re: Filename pipe to load data in SAS UE

So you can read the files using your macro, or...?

I think that UE is in lockdown state, which means that OS commands cannot be used.

On way around would be to use the external file functions, dinfo and dread specifically for directory listing.

Data never sleeps
Super User
Posts: 7,124

Re: Filename pipe to load data in SAS UE

I moved the question to the proper forum.

 

You can't use filename pipe in UE, as that would require XCMD enabled, which is not the case with SAS UE.

I recommend to create the list of files with tools of the host operating system, and then read the result from SAS UE.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Super User
Posts: 7,565

Re: Filename pipe to load data in SAS UE

Hi,

 

A few questions.  You say you are reading in several files, looking at the code these are CSV.  However you have attached an XLS file?  Also, please avoid attaching files, they are a security risk.

Another question, what is it your doing, UE SAS is a learning tool, for learning the SAS language, its not for a production environment, hence several features are removed, such as pipes.  

Are all the CSV files the same structure, if so then you can use a wildcard in the infile to read all them and ignore the first obs of each file.  Can find the post if this is the case.

 

Frequent Contributor
Posts: 91

Re: Filename pipe to load data in SAS UE

I attached an *.xls file because the app will not allow me to attach *.csv
files.

If I don't attach files should their content be included within the text?

I was actually trying to run some code that I had run with SAS 9.3 to use it
for a class but as stated pipes are not part of SAS UE.

All of my files are *.CSV files so I will look for the post which you
suggested and give it a try.
Solution
‎08-14-2017 01:46 PM
Super User
Posts: 18,603

Re: Filename pipe to load data in SAS UE

@jacksonan123 The appendix has a sample macro that lists all file that doesn't use PIPE commands, I think this one does work on SAS UE, but haven't tested it. It does note that it doesn't work in a Locked down state and SAS UE may be locked down.

 

http://support.sas.com/documentation/cdl/en/mcrolref/69726/HTML/default/viewer.htm#n0js70lrkxo6uvn1f...

 

Super User
Posts: 18,603

Re: Filename pipe to load data in SAS UE

Why are you using filename in the first place? If they're all in the same folder with the same format you can read them all at once:

https://communities.sas.com/t5/SAS-Communities-Library/How-do-I-write-a-macro-to-import-multiple-tex...

 

 

Super User
Super User
Posts: 7,565

Re: Filename pipe to load data in SAS UE

Frequent Contributor
Posts: 91

Re: Filename pipe to load data in SAS UE

I tried to use the code posted on the site:


-all-TSV-files-in-a-folder/m-p/273039#M18938>
https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-import-and-merge-
all-TSV-files-in-a-folder/m-p/273039#M18938

data _null_;

infile "/folders/myfolders/FOCALIN_QUAL_SAS/0BOOT/MEDVALGRAPHS/*.csv";

file "/folders/myfolders/FOCALIN_QUAL_SAS/0BOOT/QUAL_GRAPHS2/*.csv";

input time rep nobs y_median;

run;

I get the following error:

ERROR: Physical file does not exist,
/folders/myfolders/FOCALIN_QUAL_SAS/0BOOT/MEDVALGRAPHS/*.csv.

ERROR: Invalid physical name.



I looked in the folder MEDVALGRAPHS in the folder 0boot and it indeed
contains n number of files medgrsim1-10.csv.

I used the wild card designation per the example but I still got the error.
Can you tell me what I have done wrong and how to correct my mistake.

Thanks
Super User
Posts: 18,603

Re: Filename pipe to load data in SAS UE

1. Why is it a data _null_ step if you're importing data?

2. Why do you have a FILE and INFILE statement?

3. Did you review the link I posted? I suggest you try that approach which is laid out step by step.

 

Frequent Contributor
Posts: 91

Re: Filename pipe to load data in SAS UE

I tried the macro at :




wer.htm#n0js70lrkxo6uvn1fl4a5aafnlgt.htm>
http://support.sas.com/documentation/cdl/en/mcrolref/69726/HTML/default/view
er.htm#n0js70lrkxo6uvn1fl4a5aafnlgt.htm

and it solved the issue. I will post it as such. One quick question, I
found that % sign can be used as a wild card for SAS but it doesn't seem to
work for SAS EU. Do you know why or is there a better one ?
Super User
Posts: 18,603

Re: Filename pipe to load data in SAS UE

% is a 'wildcard' in WHERE statements or in PROC SQL. The implementation is the same across all SAS installations AFAIK.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 13 replies
  • 401 views
  • 1 like
  • 5 in conversation