BookmarkSubscribeRSS Feed
Cyclist
Calcite | Level 5

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").

 

 

4 REPLIES 4
Ksharp
Super User
data _null_;
input x $20.;
want=scan(x,1,,'kd');
put x= want=;
cards;
32/2/1 
Top 211
;
run;
Cyclist
Calcite | Level 5

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

Ksharp
Super User
Are you using DI , BI , EG ? Create a new program and run this code .
Cyclist
Calcite | Level 5

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-...

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 1085 views
  • 0 likes
  • 2 in conversation