0
votes

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;
2
Why do you need to have the var2344... field called exactly that? Simply rename it to something shorter & clearer.Chris J
Hi I have 45 variables that way, I received this file and now I want to import that file to SAS and work on it.user3658367

2 Answers

3
votes

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;
1
votes

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.