BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
SteelersPitts
Obsidian | Level 7

Hi, 

 

I'm trying to set data in a table by reading a file. However, SAS is not able to recognize the file. Any suggestion is highly appreciated.

 

File: ABCD_062018 (This is monthly file with a date stamp, therefore I want to use a wild card to read the file and make it date independent)

 

File Location: C:\Desktop\Folder

 

Now in SAS I'm creating a lib as follows:

 

Libname Path C:\Desktop\Folder

 

Data Table;

Set Path."ABCD_%";

Run;

 

Error:

ABCD_% is not a valid name (I've tried replacing % by *, moving the quotes, changing to single quotes but nothing works.

 

Any thoughts on how to resolve this issue?

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Is this a sas data set or text file?

 

If it's a text file, you first need to import it into SAS and create a data set. 

 

If it's a SAS data set you need to set the libname (correctly) and the wildcard is : for data set names, not % or with quotes.

 

libname myFiles 'C:\desktop\folder\';

data ABCD;
set myFiles.ABCD_: ;*will read all files with ABCD prefix;

run;

@SteelersPitts wrote:

Hi, 

 

I'm trying to set data in a table by reading a file. However, SAS is not able to recognize the file. Any suggestion is highly appreciated.

 

File: ABCD_062018 (This is monthly file with a date stamp, therefore I want to use a wild card to read the file and make it date independent)

 

File Location: C:\Desktop\Folder

 

Now in SAS I'm creating a lib as follows:

 

Libname Path C:\Desktop\Folder

 

Data Table;

Set Path."ABCD_%";

Run;

 

Error:

ABCD_% is not a valid name (I've tried replacing % by *, moving the quotes, changing to single quotes but nothing works.

 

Any thoughts on how to resolve this issue?


 

View solution in original post

2 REPLIES 2
Reeza
Super User

Is this a sas data set or text file?

 

If it's a text file, you first need to import it into SAS and create a data set. 

 

If it's a SAS data set you need to set the libname (correctly) and the wildcard is : for data set names, not % or with quotes.

 

libname myFiles 'C:\desktop\folder\';

data ABCD;
set myFiles.ABCD_: ;*will read all files with ABCD prefix;

run;

@SteelersPitts wrote:

Hi, 

 

I'm trying to set data in a table by reading a file. However, SAS is not able to recognize the file. Any suggestion is highly appreciated.

 

File: ABCD_062018 (This is monthly file with a date stamp, therefore I want to use a wild card to read the file and make it date independent)

 

File Location: C:\Desktop\Folder

 

Now in SAS I'm creating a lib as follows:

 

Libname Path C:\Desktop\Folder

 

Data Table;

Set Path."ABCD_%";

Run;

 

Error:

ABCD_% is not a valid name (I've tried replacing % by *, moving the quotes, changing to single quotes but nothing works.

 

Any thoughts on how to resolve this issue?


 

SteelersPitts
Obsidian | Level 7

You're awesome! Thanks! 

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
  • 2 replies
  • 465 views
  • 3 likes
  • 2 in conversation