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

How can I set these data sets with names: Fit_1, Fit_2, Fit_5, ..., Fit_1000.

I can not run with this:

##############################

data fit;

set Fit_1 - Fit_100;

output;

run;

##############################

Error: work.fit_3 does not exist.

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

if you don't have any other data sets whose names start with FIT_ try:

 

data want;

   set fit_: ;

run;

 

Other wise if you have "numbers" that don't match you leave them out of the stated sequence:

 

Data want ;

   set fit_1 fit_2 fit_4-fit_15 fit_17 - fit_30 ...;

Assuming that the names listed exist and that the ranges where indicated are complete.

View solution in original post

4 REPLIES 4
ballardw
Super User

if you don't have any other data sets whose names start with FIT_ try:

 

data want;

   set fit_: ;

run;

 

Other wise if you have "numbers" that don't match you leave them out of the stated sequence:

 

Data want ;

   set fit_1 fit_2 fit_4-fit_15 fit_17 - fit_30 ...;

Assuming that the names listed exist and that the ranges where indicated are complete.

Reeza
Super User

Here is a reference that illustrates how to refer to variables and datasets in a short cut list:
https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html

 

What happens if you try the double dash instead or colon operator?

 


@mezerji wrote:

How can I set these data sets with names: Fit_1, Fit_2, Fit_5, ..., Fit_1000.

I can not run with this:

##############################

data fit;

set Fit_1 - Fit_100;

output;

run;

##############################

Error: work.fit_3 does not exist.


 

TomKari
Onyx | Level 15

If all else fails:

 

proc sql noprint;
	select memname into: TableNames separated by " " from dictionary.tables
		where libname = "WORK" and substr(memname, 1, 3) = "FIT" /* Must be uppercase */
	order by memname;
quit;

%put &TableNames.;

data fit;
	set &TableNames.;
	output;
run;
Ksharp
Super User
Add one option:

options nodsnferr ;
data fit;
set Fit_1 - Fit_100;
run;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 1555 views
  • 6 likes
  • 5 in conversation