SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Extracting Number From the Left Side From String

Reply
Contributor
Posts: 23

Extracting Number From the Left Side From String

I have a column "House number" which besides numbers contains also something like this "32/2/1" or "Top 211".

The column is defined as TEXT.

My question is: how can I extract only first number from the string such as ""32/2/1"?

(the expression needs to correctly extract the number when only a number stands in the field such as "32").

 

 

Super User
Posts: 10,044

Re: Extracting Number From the Left Side From String

data _null_;
input x $20.;
want=scan(x,1,,'kd');
put x= want=;
cards;
32/2/1 
Top 211
;
run;
Contributor
Posts: 23

Re: Extracting Number From the Left Side From String

Since I am new to SAS, can you tell me how to use your expression and how to integrate it into my data job?

Super User
Posts: 10,044

Re: Extracting Number From the Left Side From String

Are you using DI , BI , EG ? Create a new program and run this code .
Contributor
Posts: 23

Re: Extracting Number From the Left Side From String

I am using Data Management Studio 2.7.

 

Please have a look at my other post which is connected to this question:
https://communities.sas.com/t5/SAS-Data-Management/Extracting-Street-House-Number-and-Door-Number/m-...

Ask a Question
Discussion stats
  • 4 replies
  • 322 views
  • 0 likes
  • 2 in conversation