Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Matching part of a string of characters

Status
Not open for further replies.

spudgunr

Technical User
Feb 13, 2009
2
US
I have variable I defined as being 50 characters long that contains information I need to access in the format ,#,#, where # is a single digit 1-9. Unfortunately, this 50 characters is a free-write comment and so the data I'm looking for won't be in any given position. I am self-taught with sas so my methods are often unorthodox at best. I have the following piece of code:

DO I=1 TO 9;
DO J=1 TO 9;
X=PUT(I,1.);
Y=PUT(J,1.);
IF UNIT = 'DCRT' AND COMMENT = :'C1' AND
(INDEX(COMMENT,',X,Y,') > 0 )
THEN NUMBER='MULTIPLE';

END;
END;

I am trying to search the 50 character "comment" variable to match data that can be in that ,#,#, format. I know for a fact there are results that match this format, but my "number" variable remains blank. Any suggestions? Again, the ,#,#, can be ,1,5, or ,5,1, with numbers between 1-9 in either position. I am not getting any errors on this code, but no results either.

FWIW: I can't use macros, interactive modes, or many other common things. I use batch mode only because the program is installed on a remote server.
 
Nevermind, I finally figured it out. Pretty simple....but I'm not exactly programming minded. Quotes were keeping it from registering variables.

DO I=1 TO 9;
DO J=1 TO 9;
X=PUT(I,1.);
Y=PUT(J,1.);
Z=","||X||","||Y||",";
IF UNIT = 'DCRT' AND COMMENT = :'C1' AND
(INDEX(COMMENT,Z) > 0 )
THEN NUMBER='MULTIPLE';
END;
END;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top