BookmarkSubscribeRSS Feed
R_A_G_
Calcite | Level 5
Hello,

I have 150 files named TEMP_&seed

seed=1 to 150

I want to stack them in order but when I use the following syntax they files are not ordered right. Why?
my codes:
data SAP.result;
set SAP.TEMP_:;
run;
Thank you
11 REPLIES 11
Peter_C
Rhodochrosite | Level 12
You are going to need to take control.
PROC SQL noprint ;
Select memname, input( scan( memname, -1, '_' ), best8.) as suffix_number
Into :name_list separated by ' ' , :other
From dictionary.tables
where libname = 'SAP' and memname like 'TEMP%'
Order by suffix_number
;
data_null__
Jade | Level 19
Use

set temp_1-temp_150 open=defer; Removed slash / from SET statement, would cause an error.


Message was edited by: data _null_;
R_A_G_
Calcite | Level 5
thank you that simple set statement works
R_A_G_
Calcite | Level 5
Hello,
I was wondering what does " / open=defer" do in that statement?

Thanks
ArtC
Rhodochrosite | Level 12
the open=defer causes the data sets to only be opened when they are ready to be read. Otherwise all 150 data sets would have to be open at one time (the default). Under some (most I would assume) OSs there are limits as to the number of open data sets.

Using the colon operator in your original code allowed the data sets to be read as they were encountered, which was apparently not in named order.
data_null__
Jade | Level 19
Don't use the / that was an error.

As mentioned OPEN=DEFER does just that defers opening the files until they are read. The files must contain exactly the same variables to use Deferred opening which you implied. If not you may have to concatenate in smaller groups.
Ksharp
Super User
How about:
[pre]
data SAP.result;
set SAP.TEMP_:;
by id;
run;
[/pre]

Ksharp
R_A_G_
Calcite | Level 5
Hi KSharp,

The id code does not work. I need these files to be stacked in order. Ex: 1st OUT1 2nd OUT2, 3rd OUT3 and so on.

thanks
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
To the OP: Peter.C provided you a suitable solution, where a macro variable is generated and you have total control how you might want to sequence the files. Have a look back at the thread for details.

Scott Barry
SBBWorks, Inc.
Ksharp
Super User
Oh.I misunderstood what you mean.But you can use variable listing to get it.I tested it successfully by SAS 9.2

[pre]
libname xx 'c:\temp';
data want;
set xx.makedata1 - xx.makedata4;
run;
[/pre]


Ksharp
R_A_G_
Calcite | Level 5
thanks Ksharp this simple and short code works well.
R.A.G.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 11 replies
  • 1548 views
  • 0 likes
  • 6 in conversation