BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
danielelamendol
Calcite | Level 5

Hi, I just started using sas,

I have a column in which I have both the VAT numbers and the tax codes of the subjects.
There are some VAT numbers that have fewer digits than they should have (they should have 11 but sometimes they are 10 or 9 or 8), in particular the zeros are missing at the beginning.
So since I saw that there is Zw.d. format, which allows you to add missing zeros, but is only applicable to numeric variables, and so I wanted to select within this column only the numeric variables, apply the format and bring the two parts together.

 

if there is another method to my main problem i'm glad to know,

 

thanks

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

@danielelamendol welcome 🙂

 

Problems like this is much easier to solve if you provide some example data that resembles your actual data. Makes it much easier to provide usable code that you can apply to your actual data.

View solution in original post

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20

@danielelamendol welcome 🙂

 

Problems like this is much easier to solve if you provide some example data that resembles your actual data. Makes it much easier to provide usable code that you can apply to your actual data.

danielelamendol
Calcite | Level 5
ok, thank you for your advice.
I can't show the real data but,

I have a column called user_id which contains values like:

123456789
12345678
9862416351
(which are the VAT numbers)
in the same used_id column there are also other values like:
lcnfno19f44h273g
frcfvr77d31z976m
(which instead is the tax code (in Italy))

both types of values are user identifiers.

the first 3 lines of the example are 9,8,10 digits respectively, but should be 11, this is because when downloading the excel file from the portal from which I got the data, the USER_ID column was probably loaded as numerical and did not consider the first digits of the VAT number which are zero.
so the column values I would like to get are:
00123456789
00012345678
09862416351

and leave the other lines referring to tax codes unchanged.

to do this I saw that the zw.d format can be applied, which however is only applicable to numeric values. but I don't know how to select only the numeric values of the USER_ID column.

I hope I was clearer.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1358 views
  • 0 likes
  • 2 in conversation