Max
Max

Reputation: 857

SAS Numbered Range Variable Lists with Character Variables and Column input

I am trying to use a Numbered Range Variable List with character values and column input.

Data question;
input ques1 $ 1 ques2 $ 2 ques3 $ 3 ques4 $ 4 ques5 $ 5;
datalines;
ABCDE
AACCE
BBBBB
CABDA
DDAAC
CABBB
EEBBB
ACACA
;

How can I re-write that input line in the form of a variable list

input ques1-ques5;

And specify both the columns and characters $?

Thanks!

Upvotes: 1

Views: 307

Answers (1)

Joe
Joe

Reputation: 63424

Like this:

Data question;
input @1 (ques1-ques5) ($CHAR1.);
datalines;
ABCDE
AACCE
BBBBB
CABDA
DDAAC
CABBB
EEBBB
ACACA
;
run;

I've changed two things. First, I've set it up to read in column format instead of list format; this allows the second change to work. The second change is to group the five ques's and then group the format with matching parentheses. This won't quite work in list format, unless there are delimiters between your inputs.

Upvotes: 0

Related Questions