如何使用SAS将字符串拆分为两个变量

use*_*725 4 sas dataset

  1. 我有一个数据集如下:

    country
    United States, Seattle
    United Kingdom, London
    
    Run Code Online (Sandbox Code Playgroud)

如何将国家分成SAS中的数据,如:

    country                  city
    United States           Seattle
    United Kingdom          London
Run Code Online (Sandbox Code Playgroud)

Dmi*_*pin 16

使用函数SCAN()以逗号作为分隔符.

data test;
  set test;
  city=scan(country,2,',');
  country=scan(country,1,',');
run;
Run Code Online (Sandbox Code Playgroud)