variable length field

Reply
Contributor
Posts: 20

variable length field

Hi I have a city,state field - variable length.  I need to output the city and in another field output the state field.  Basically have one field but need to output two fields but it is variable:  For example:  New York, NY

                                                                                           Rye, NY

                                                                                           White Plains, NY

Super User
Posts: 7,386

Re: variable length field

Use the scan() function. Like

 

city = scan(city_state,1,',');
state = scan(city_state,2,',');

Take care of defining the target fields with appropriate lengths.

 

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 1 reply
  • 150 views
  • 2 likes
  • 2 in conversation