Hello, This is my first time posting -- please excuse me if it is confusing. I am currently reading a text file into SAS. Because the data was character delimited but follows an inconsistent pattern, I originally read the text file into SAS and saved it as a SAS file such that all of the variables and associated data within the delimiters was saved as a single variable (entered here as Var_umbrella). I am now attempting to split the catch-all variable into multiple columns. The original file is delimited with the vertical bar " | ", but the variable names are included inside the delimiter. The complicating factor is that each row/observation does not include all of the variables; if the variable was blank for that row, it was omitted from the data entirely for that row (that is not something I can change, unfortunately. The data was given to me as-is and the source will not make adjustments to it). This is what it looks like: Case # Var_umbrella Row 1 |Var_1 a | Var_2 b | Var_3 c | Var_4 d | Var_5 e | Row 2 |Var_1 f | Var_4 g | Row 3 |Var_2 h | Var_3 i | Var_5 j | Row 4 |Var_5 k| This is what I am trying to get it to look like: Obs # Var_1 Var_2 Var_3 Var_4 Var_5 Row 1 a b c d e Row 2 f . . g . Row 3 . h i . j Row 4 . . . . k I tried using the index and =scan(var,n,'delimiter') functions as follows to create the new columns: data want; data have; if index(Var_umbrella,'Var_1')>0 then Var_1=scan(Var_umbrella,1,'|'); if index(Var_umbrella,'Var_2')>0 then Var_2=scan(Var_umbrella,2,'I'); if index(Var_umbrella,'Var_3')>0 then Var_3=scan(Var_umbrella,3,'I'); if index(Var_umbrella,'Var_4')>0 then Var_4=scan(Var_umbrella,4,'|'); if index(Var_umbrella,'Var_5')>0 then Var_5=scan(Var_umbrella,5,'I'); run; This worked perfectly for the first variable but does not read in the following variables correctly because the position of each variable (n) is inconsistent across the rows. Please advise! Thank you for any input, and I am happy to provide additional clarification as necessary. -Miranda
... View more