How to set data in a table?

Accepted Solution Solved
Reply
Contributor
Posts: 24
Accepted Solution

How to set data in a table?

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?


Accepted Solutions
Solution
a month ago
Super User
Posts: 24,010

Re: How to set data in a table?

Posted in reply to SteelersPitts

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


All Replies
Solution
a month ago
Super User
Posts: 24,010

Re: How to set data in a table?

Posted in reply to SteelersPitts

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?


 

Contributor
Posts: 24

Re: How to set data in a table?

You're awesome! Thanks! 

☑ This topic is solved.

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

Discussion stats
  • 2 replies
  • 66 views
  • 3 likes
  • 2 in conversation