user3658367
user3658367

Reputation: 641

import text file tab delimiter with variable name more than 32 chars

I am trying to import a text file with tab delimiter which has two variables.

ID var234488hhfyggyhuur_jhjhuytsdrkkjuht_kjy
1  5,6
2  10
3  122,5
4  0,6

I am able to import the file but not in the right format of the seciond variable and also the variable name is more than 32 char long.

data exam1;
infile "C:\Users\gght\Desktop\today.txt" firstobs=2 dlm='09'x ; 
input id 3. var234488hhfyggyhuur_jhjhuytsdrkkjuht_kjy numx12.2; 
run;

Upvotes: 0

Views: 117

Answers (2)

Reeza
Reeza

Reputation: 21274

Use a label to capture the variable name and use a generic variable name to import the data.

data exam1;
infile "C:\Users\gght\Desktop\today.txt" firstobs=2 dlm='09'x ; 
label var2 = 'var234488hhfyggyhuur_jhjhuytsdrkkjuht_kjy';
input id 3. var2 numx12.2; 
run;

Upvotes: 3

Altons
Altons

Reputation: 1424

I am afraid there is no other way. You will have to rename the vars explicitly after the import of the file in SAS. It is well worth doing this once and re-using code if this file is something you're going to get with some frequency.

You can easily create your input statement in excel and copy-paste in your SAS program.

Upvotes: 1

Related Questions