Automated import of dynamic labeled files into SAS


    Sponsored Links


  • 1. need SAS programmer in San Antonio, TX
    We are looking for an experienced SAS programmer, preferably with pharmaceutical experience. Macro knowledge a must. Thanks!
  • 2. read zss into SPSS
    I have just downloaded some datafiles from the site. They were zipped so I unzipped them and have them in my directory with a .zss extension. But my SPSS 11 does not recognise them. How can I read them into SPSS? Thanks for the help. Jan
  • 3. Input comma delimited file
    Hi, I have a beginner's question. I used the following codes to input a comma delimited file with 2 variables, email (min 19, max 46) and customer number (min 7, max 8). But I am only getting the first 8 columns in the email field. How do I correct it? DATA TEST; INFILE FILEIN1 DLM=','; INPUT EMAIL $ CUST_NUM; PROC PRINT DATA = TEST (OBS=250); RUN; Obs EMAIL CUST_NUM 1 RJBEAN10 1005661 2 CAROLGEL 1050773 3 JLCRIBBS 1063455 4 UTA@SONG 1073812 5 MYRNA@EP 1114518 Thank you very much for your help! Lu
  • 4. Is Proc GLM obsolete?
    Since PROC MIXED can analyze datasets in which all factors are fixed, has PROC MIXED made PROC GLM obsolete? If I've got a few classes to introduce students to SAS is there any reason for showing them GLM (other than that people still use it, which I'm not sure is reason enough) or should I spend the time on PROC MIXED alone? Thanks!

Automated import of dynamic labeled files into SAS

Postby Tom » Tue, 10 May 2005 01:31:01 GMT


I want to write a SAS-Base program which is able to import dynamic
labeled files into SAS. The filenames have no specific pattern. Only
one part of the filename is static. For example:
File 1: attach_first.txt
File 2: attach_hour.txt
File 1000: attach_town.txt

The structure of the file content is in every file the same.

Exist in SAS wildcards to read in these Files?

I would be happy to get a solution!

A lot of Greetings from Germany.


A normal SAS-program with proc import looks like:
proc import datafile="D:\Service\Research\attach_first.txt"

Re: Automated import of dynamic labeled files into SAS

Postby datametric » Tue, 10 May 2005 18:00:24 GMT


Where are your file ? Are they in a folder ?
Where are your file names ? anywhere or into a separate file ?

Part A : you could create a data with a CARDS statement containing the file names. (copy/paste the list into the CARDS)

Otherwise, I suggest you to create a PIPE Step which read a folder and retain the file names.

See the 2005 archive of SAS-L about theses ways.

You'll have your list into SAS.

Part B : Create a loop based on this list to use the proc import.
The loop could be created via a %do loop or a CALL EXECUTE statement into a data step.
See the 2005 archive of SAS-L about these ways.


----Message d'origine----

Re: Automated import of dynamic labeled files into SAS

Postby nospam » Thu, 12 May 2005 11:24:43 GMT

The answer is "yes, but ...".

You could code

   proc import datafile="D:\Service\Research\attach_*.txt"

but that will pull everything into one SAS data set and will misinterpret
the GETNAMES lines from all files other than the first.

Similar Threads:

1.automating data (excel) import in sas

Hello All, 

I have a question that i hope someone can help with..I recieve several
excel files each week all constructed in the same format ie..having
the same variables in the same order..I wish to import these into sas
and ultimately combine (concatonate) the data into one master sas
dataset. I have created a program that completes this task, using a
series of proc import statements (one for each excel files). While
this is working, I have to modify the import statements each week to
accomodate the new excel file names..

I am trying to figure out a way that i can import several excel sheets
using one import statement..Ultimately i would like to be able to just
drop each excel sheet in a folder and have sas import each one without
having to change my import statements to accomodate the different
excel file names...I am not sure if this is clear enough...please let
me know if i need to elaborate..Thanks, Nevin

Nevin Krishna
Epidemiology Supervisor
Louisiana Office of Public Health
Infectious Disease Epidemiology
New Orleans La

2.SPSS data file to SAS data file: only partial variable labels

Dear fellow SAS users:

I am trying to convert an SPSS data file (.sav, not .por) to SAS, using
SPSS version 15 for Windows. The data file is large, but not huge (176
cases, 963 variables). I have SAS 9.1.3 on Windows XP.
I used the following commands, and got the Warning message that "excess
labels will be omitted." (See below) SPSS successfully copied over the
variable labels for the first 2/3 of the variables, but then just stopped.
The wording of the message ("cumulative length of the variable labels
exceeds the limitations of the target file type") suggests that there is
some limitation of memory size involved.
Incidentally, I did succeed in getting the value labels captured in a
separate file containing SAS statements.
So the question is: Is there any way I can increase a default memory or
buffer size to allow SPSS to copy all the variable labels?

Thanks for any suggestions.

Joe Hoffman

Here's my code and message:

get file = 'G:\q556\data\Master_file\master.sav'.
SAVE TRANSLATE OUTFILE='G:\q556\data\Master_file\master.sas7bdat'
  /VALFILE='G:\q556\data\Master_file\' .

>Warning # 9077
>The cumulative length of the variable labels exceeds the limitations of
the target file type.  The excess labels will be omitted.

Data written to G:\q556\data\Master_file\master.sas7bdat.
963 variables and 176 cases written.
Variable: ID                 Type: Number   Width:  12   Dec: 0
Variable: SIA1               Type: Number   Width:   3   Dec: 0
. . . . .
Joseph H Hoffman
Data Analyst
Research Institute on Addictions
State University of New York at Buffalo
1021 Main Street
Buffalo NY 14203
phone 716-887-2219
FAX 716-887-2510
e-mail   XXXX@XXXXX.COM 

3.dynamic label assignment

Hi all,

I am trying to assign the column label during the data step but I
can't figure out how to do it. Here is the question. Several dates are
generated during the iterations. Each date is stored in an individual
column. I'd like to change the name of each of these columns to the
date it contains. Below is part of the code. Could anyone offer any


=== code ===
Libname Lib 'c:\test';

Data test;
set Lib.test;
array col(3) c1-c3;
array dat(3) d1-d3;

Do i = 1 to 3;
    d = intnx('month', '31jan2008', i);
    dat(i) = d;
    /* label c1 = put(d, date7.); */

4.Dynamic label fore ALL variabel in Proc Tabulate

I want to dynamic set the label fore the ALL variabel in Proc Tabulate.

I want to write the code somthing like this:
table sex* (age all='Total: ' || sex.value), Tv*SUM='';

In the output:
20             2
25             3
30             2
35             5
Total: MALE    12


How can this be done???

/Anders Johansson

5.Dynamic file creation thru SAS

Hi All,
   We have SAS on mainframe.
I have situation where I need to dynamically create the file for each
unique Warehouse number. Below is the code I created to dynamically
allocate the files in mainframe.It is running fine for all the
situations except if there is out of space error. In other words the
file I am allocation has some default space limit if it exceeds that
limit my job getting failed.
My question:
   Is there any way I could increase/control the size of the output
file while creating the file dynamically. I have controlled the file
record length by using LS statement. I appreciate all your help.


Please find the below code:

Data Sas1;
Infile Whsefile;
Input @001 Whse    $char05.;
          @006 Items    $char100.;

Proc Sort;
By Whse;

data _null_;
set sas1 end=x; by Whse;
if _n_ = 1 then do;
   file print notitles;
   put / '               files created in this            ' /
         '              **************************        ' ;

if first.whse then do;
   length fname $44.;
   fname=compress('myuid.whse.w'|| Whse||'.csv');
   link file_delete;

file dummy filevar=fname mod recfm=fb Ls=105;
put @001 Whse $char05.;
      @006 Items $char100.

if x then do;
file print notitles;
put /
    'count of files generated : ' cnt;

if rc = 0 and fexist(fn) then do;
if rc1  0 then do;
   put 'file deletion not successful';
   abort abend;

6. Dynamic allocation of output files in a SAS program

7. SIMULATION: results output in an external file & automate the

8. Problem with importing excel file using PROC IMPORT.

Return to sas


Who is online

Users browsing this forum: No registered users and 10 guest