...
> I am importing a txt file into SAS and looking only
> for rows that contain the four types of text strings
> below ("date", "ini", "type", "case"). Four rows at a
> time are related to the same case number. The
> challenge is that the order of type and case is not
> always the same in the text file and so I would like
> to sort by case number to obtain the same order in
> all by-groups (and use proc transpose afterwards).
...
If I understand correctly, then you want to read from a text file with only the rows that have all of these four keyword: value pairs. Only the problem is that the orders of type and case change. No problem. Use absolute column pointer controls. Hope this helps a bit.
[pre]
data cases;
length date ini type $8;
input @1 @("date:") date $
@1 @("ini:") ini $
@1 @("case:") case
@1 @("type:") type $;
/* all four should not be missing */
if not missing(date) & not missing(ini) &
not missing(case) & not missing(type) then
output;
cards;
date:xxx ini:hli type:l case:123
date:yyy ini:lbj case:587 type:l
date:zzz ini:jcg type:t case:789
;
run;
/* check */
proc print data=cases;
run;
/* on log
Obs date ini type case
1 xxx hli l 123
2 yyy lbj l 587
3 zzz jcg t 789
*/
[/pre]
... View more