How to use SAS to split a string into two variables

Viewed 65229
  1. I have a dataset as below:

    country
    United States, Seattle
    United Kingdom, London
    

How can I split country into a data in SAS like:

    country                  city
    United States           Seattle
    United Kingdom          London
3 Answers

Response to:

data test;
  set test;
  city=scan(country,2,',');
  country=scan(country,1,',');
run;

What if I want to split the last comma in the string only, keeping 7410 City?

Example: "Junior 18, Plays Piano, 7410 City

Related