DATA Step, Macro, Functions and more

Create columns from a string

Reply
Super Contributor
Posts: 673

Create columns from a string

how to create three columns from a string?i will get these values in a txt file and the string length can vary.

AZERBAIJAN                                      AZ      AZE     031

Country=AZERBAIJAN                                    

Country_code=AZ/AZE

Dial_code=031

PROC Star
Posts: 7,474

Re: Create columns from a string

Will the string always contain 4 strings within it?

Super Contributor
Posts: 673

Re: Create columns from a string

Hi,

Yes.

PROC Star
Posts: 7,474

Re: Create columns from a string

data want;

  input;

  Country=scan(_infile_,1);

  Country_code=catx("/",scan(_infile_,2),scan(_infile_,3));

  Dial_code=scan(_infile_,4);

  cards;

AZERBAIJAN                                      AZ      AZE     031

;

Ask a Question
Discussion stats
  • 3 replies
  • 147 views
  • 0 likes
  • 2 in conversation