BookmarkSubscribeRSS Feed
aswinappus
Calcite | Level 5

Hi,

 

Is there any SAS options or an easy way to read a file in proc import filename without accounting the case sensitivity.

 

Eg: I need to import a file using proc import  from a user who place it in a unix folder.. It is possible that user name it like myfile.xlsx / Myfile.xlsx / MyFile.xlsx etc.... I would need my code to handle it instead of giving an ERROR like "Physical file does not exist"

 

I can always look for certain keywords in the file name and can pick it by writing detailed code, but wondering if there are any easy option that could just ignore the case of the filename?

4 REPLIES 4
Tom
Super User Tom
Super User

No.

 

You could ask the operating system to give you list of all of the files and then pick the one you think is the one you want.

aswinappus
Calcite | Level 5
Thanks Tom
ballardw
Super User

Options no but code should work.

 

I would be tempted to pipe an LS command to populate a data set, create an uppercase value in a different variable and then match my expected value as uppercase to select the mixed case and place that into a macro variable. Either use options to get the path as part of the filename OR use a concatenation function to prefix the name with the proper string.

 

filename listing pipe 'ls' <options>;

data  names;
   infile listing;
   length name $ 200 ;
   input name;
   if upcase(name) = "The path and file I expect" 
      then call symputx('sourcefile',name);
run;

proc import datafile="&sourcefile."
   out=lib.datasetname
   dbms=xlsx;
   <other options>
   ;
run;

Been way to long since I did any work on a Unix (or other system) do know what the full syntax option might be for the listing command.

Do not use any option that would list the names as all upper or lower case.

aswinappus
Calcite | Level 5
Thanks.. I'm currently using a similar approach, but this logic looks much simpler than what I have.. THANK YOU!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1222 views
  • 1 like
  • 3 in conversation