Place portion of text from a variable into new variable

Reply
Contributor
Posts: 34

Place portion of text from a variable into new variable

I have a dataset that has one field, "progNote" with max size=32767. This variable contains some information I am interested in. I want to extract a portion of the text in this variable and place into a new variable. The begining of the text I want to extract is always the same which is "MILITARY HISTORY:". I want to extract text starting from the M in Military to 300 characters after for all records. Is there a way to do this in SAS. Thanks.
Super Contributor
Posts: 260

Re: Place portion of text from a variable into new variable

Something like :
[pre]
LENGTH excerpt $ 300 ;
start = INDEXW(progNote, "MILITARY HISTORY") ;
IF start > 0 THEN excerpt = SUBSTR(progNote, start) ;
[/pre]
may solve your problem.

Olivier
Contributor
Posts: 34

Re: Place portion of text from a variable into new variable

Sorry I haven't gotten back sooner. I acutally solved my problem using VBA and Access. Thanks.
Post a Question
Discussion Stats
  • 2 replies
  • 282 views
  • 0 likes
  • 2 in conversation