Hello,
I tried out this logic and seemed to work ..... may be a round about way but, I believe it might work for what you are trying to do...
I have created 2 dummy files within my datalines. One file reads the var as numeric (first file) and the second file reads the same variable as character so as to simulate what you have in your EXCEL import. So , now, we have 2 datasets having the same variable defined as char and numeric. What this code does it that irrespective of the type of data definition, it just writes into a text file and reads. In the next step reads the data as character so all data is converted to character. Once you have every file processed through the same cycle, you will have all files in character format and set to one dataset. At the end, you can do one formatting of the variables as you need it as either numeric or char per your requirement in the output. For efficiency and space concerns, the macro reuses the same work file and you may chose to use the same sas dataset name as your imported dataset name if you like to reuse the same name; in this example, I've isolated it separately as ds1, ds2 which you may reuse as in1, in2.
filename file1 '/folders/myfolders/testfile.txt';
data in1;input v1:1.;
datalines;
1
2
3
;
RUN;
data in2;input v1:$1.;
datalines;
1
4
5
6
;
RUN;
%macro read_as_char(indsn,workfilename,outdsname);
data _null_;
file &workfilename;
set &indsn;
put v1;
run;
data &outdsname;
infile &workfilename;
input v1:$1.;
RUN;
%mend read_as_char;
%read_as_char(in1,file1,ds1);
%read_as_char(in2,file1,ds2);
data final;
set ds1
ds2;
run;
proc print data=final;
proc contents data=final;
run;
Here are the results displayed for your reference:
Obs v1
1 1
2 2
3 3
4 1
5 4
6 5
7 6
The CONTENTS Procedure
Data Set Name WORK.FINAL Observations 7
Member Type DATA Variables 1
Engine V9 Indexes 0
Created 10/30/2015 10:52:28 Observation Length 1
Last Modified 10/30/2015 10:52:28 Deleted Observations 0
Protection Compressed NO
Data Set Type Sorted NO
Label
Data Representation SOLARIS_X86_64, LINUX_X86_64, ALPHA_TRU64, LINUX_IA64
Encoding utf-8 Unicode (UTF-8)
Engine/Host Dependent Information
Data Set Page Size 65536
Number of Data Set Pages 1
First Data Page 1
Max Obs per Page 58218
Obs in First Data Page 7
Number of Data Set Repairs 0
Filename /tmp/SAS_work44E50000605B_localhost.localdomain/SAS_work15C70000605B_localhost.localdomain/final.sas7bdat
Release Created 9.0401M3
Host Created Linux
Inode Number 275746
Access Permission rw-rw-r--
Owner Name sasdemo
File Size 128KB
File Size (bytes) 131072
Alphabetic List of Variables and Attributes
# Variable Type Len
1 v1 Char 1
Hope this helps.... Good luck...!!!
... View more