Help using Base SAS procedures

Extract first 8 digits left of the number

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 145
Accepted Solution

Extract first 8 digits left of the number

Hi

I would like to pull out the first 8 digits to the left of the number........the numbers marked in yellow should be discarded.....

295999335

295999333

295999336

295999337

Thanks


Accepted Solutions
Solution
‎08-25-2014 09:17 AM
Super User
Posts: 10,020

Re: Extract first 8 digits left of the number

Posted in reply to rakeshvvv

This variable is character or numeric ?Assuming it is character.

data have;

set have;

length want $ 8;

want=variable;

run;

View solution in original post


All Replies
Solution
‎08-25-2014 09:17 AM
Super User
Posts: 10,020

Re: Extract first 8 digits left of the number

Posted in reply to rakeshvvv

This variable is character or numeric ?Assuming it is character.

data have;

set have;

length want $ 8;

want=variable;

run;

Frequent Contributor
Posts: 145

Re: Extract first 8 digits left of the number

Thanks...Can you suggest a solution if the variable is Numeric....

Trusted Advisor
Posts: 1,228

Re: Extract first 8 digits left of the number

Posted in reply to rakeshvvv

For numeric you can try something like this

data want;

set have;

want=int(variable/10);

run;

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 1311 views
  • 1 like
  • 3 in conversation