Reputation: 617
I have a raw data file like this:
JamesBrownSenior
AshleyPinkJunior
The first column is name. And second is a color tag. .. But for each column, the observation length varies.
I have tried this
data ct_11;
infile '';
length Name $ 10 Tag $ 10 Title $ 10;
input Name $ Tag $ Title $;
run;
It didn't work. I guess I missed some options.
Upvotes: 0
Views: 225
Reputation: 2174
If there is no delimiter you have to read it as a single variable and then split it afterwards based on a rule. In your case tou can add a delimiter using a regular expression and then use the scan function to write the words to different variables.
data ct_11 (keep=name tag title);
infile 'z:\nametagtitle.txt';
length line $120 name tag title $40;
input line $;
dlmline = prxchange('s/([A-Z]{1}[a-z]*)([A-Z]{1}[a-z]*)([A-Z]{1}[a-z]*)/$1 $2 $3/',-1,line);
name = scan(dlmLine,1);
tag = scan(dlmline,2);
title = scan(dlmline,3);
run;
Upvotes: 1