Help using Base SAS procedures

concatenating

Reply
Regular Contributor
Posts: 161

concatenating

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
Valued Guide
Posts: 2,175

Re: concatenating

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 ' ' , Smiley Surprisedther
From dictionary.tables
where libname = 'SAP' and memname like 'TEMP%'
Order by suffix_number
;
Respected Advisor
Posts: 3,777

Re: concatenating

Use

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


Message was edited by: data _null_;
Regular Contributor
Posts: 161

Re: concatenating

thank you that simple set statement works
Regular Contributor
Posts: 161

Re: concatenating

Hello,
I was wondering what does " / open=defer" do in that statement?

Thanks
Valued Guide
Posts: 632

Re: concatenating

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.
Respected Advisor
Posts: 3,777

Re: concatenating

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.
Super User
Posts: 9,691

Re: concatenating

How about:
[pre]
data SAP.result;
set SAP.TEMP_:;
by id;
run;
[/pre]

Ksharp
Regular Contributor
Posts: 161

Re: concatenating

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
Super Contributor
Super Contributor
Posts: 3,174

Re: concatenating

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.
Super User
Posts: 9,691

Re: concatenating

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
Regular Contributor
Posts: 161

Re: concatenating

thanks Ksharp this simple and short code works well.
R.A.G.
Ask a Question
Discussion stats
  • 11 replies
  • 232 views
  • 0 likes
  • 6 in conversation