SAS: Input Raw data with different length of character variable

data map;
infile datalines delimiter=',';
length faculty $2 progname $90. facdesc $25.;
input  faculty $ progname $ facdesc $;
datalines;
AB, AB-Digital Media, , Faculty AB
AB, AB-Interdisc. Fine Arts, Faculty AB
CD,SC-Biology,Science, Faculty CD
;
run;

NOTE:

  • Can’t use Input statement to set length for the variable.  Input statement only identify the character variables by putting $ after the variable name.
  • Use ‘,’ to separate the value of the variable in the datalines; no need to put ‘;’ to end each dataline, just end the whole datalines section with one ‘;’.
  • Put Length statement before the Input statement to set the desired variable length for the data needed input.

BENEFIT:

  • No need to use “” for character values that contain spaces.
  • No need to align the variables in datalines.