Automated import of dynamic labeled files into SAS


    Sponsored Links


  • 1. Importing metadata
    I have a SAS data set and a data dictionary in Excel format. The data dictionary has two columns, one giving the variable names and one giving descriptions. I would like to import the descriptions and apply them to my SAS data set as variable labels. Any tips on how to do this? I know I can just cut and paste the Excel file into a label statement, but there are several hundred variables, and I'd like a general solution that I can apply to the next data dictionary that comes along. Thanks! Paul
  • 2. PROC MULTTEST FDR calculations do not match PROC
    We're using PROC MULTTEST to adjust p-values based on false discovery rate. After RTFM, the adjusted p-values were also computed using a data step fully expecting that the values would be extremely close. For some they are and for some they are not. Any ideas why this might be the case? Thanks. Replication code pasted below: /* Raw p-values for adjusted FDR p-value */ data raw_p; input raw_p; ID = _N_; datalines; 0.44379073 0.02759977 0.11004313 0.00212647 0.141811 0.39519877 0.02230649 0.02880425 0.01708129 0.18095402 0.01023596 0.00007119 ; run; proc multtest pdata = raw_p fdr out=adj_p; run; /* Calculate FDR_P using PROC RANK */ proc rank data = raw_p out = rankp descending; var raw_p; ranks rank; run; proc sort data = rankp; by rank; run; proc sql noprint; create table rankp2 as select *, count(*) as r from rankp; quit; data rankp2; set rankp2; retain hi_p; if rank = 1 then do; hi_p = raw_p; adj_p = raw_p; end; else adj_p = min(hi_p,r/(r-(rank-1))*raw_p); run; proc sort data = adj_p; by ID; run; proc sort data = rankp2; by ID; run; data compare; merge adj_p rankp2; by ID; if round(adj_p,1e-6) ^= round(fdr_p, 1e-6) then flag = 1; else flag = 0; run; proc print data = compare; var ID raw_p fdr_p adj_p flag; label fdr_p = 'From PROC MULTTEST' adj_p = 'Computed'; run;
  • 3. save output
    Hi everyone. Just wondering if anyone could teach me what is the sas code to save the result from the output window as a log file? thanks heaps. have a great day.

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 62 guest