12-31-2014 01:22 PM
I have a csv file that has 100s of identical variables(columns) andare all character fields.
This is my attempt to read them -I do not want to list each of them in Input statement;
Infile "abc/xys/aabb.csv" dsd firstobs=2;
INPUT Fname $ Age LName Var1-Var100;
The variable list Var1-Var100 works only for numeric variables. How do I get around if all these variables are characters?
INPUT Fname $ Age LName Var1-Var100 $ , this works only for the last variable but not for remaining 99. And if I do
INPUT Fname $ Age LName Var1 $ -Var100 $;....it throws an error.
12-31-2014 01:48 PM
It is much easier if you define the variables first and then write the INPUT statement.
data want ;
infile 'myfile.csv' dsd firstobs=2 lrecl=30000 truncover ;
length fname $20 age 8 lname $20 var1-var100 $20 ;
input fname -- var100 ;
You can also use () to apply a format to multiple variables.
input .... (var1-var100) ($) ;
Need further help from the community? Please ask a new question.