BookmarkSubscribeRSS Feed
jcis7
Pyrite | Level 9

1.  Do you see a problem wtih having a field that has different length numbers (Type 1 has 10 digits, Type 2 has 8 digiits)   that may have leading zeros  if I want to do Update the Master table with a transaction table or match merge or deduplicate?

2.  How would you export the file into MS Access with the correct number of leading zeros retained?

ID                             Type

0123948578                1

0593827108                1

2983748597                1

02498377                    2

00938478                    2

Thanks!

4 REPLIES 4
allurai0412
Fluorite | Level 6

hi,

if your question is about zeros ...please try this..

format id z5.

For  5 digits ....

format id z10.

Regards

ALLU

jcis7
Pyrite | Level 9

Thanks!  How do you export the same field with two different lengths into a MS Access database retaining the leading zeros?  The only way I can think of is if you break the 10-digit facilities into 1 dataset and the 8 digit facilites into another dataset and format them separetly using the z format?

SASKiwi
PROC Star


To ensure you retain leading zeros while exporting it would be preferable to convert ID to character columns:

if type = 1 then ID1 = put(ID, z10.);

else if type = 2 then ID2 = put(ID, z8.);

Its good practice to store IDs as character anyway so things like leading zeroes don't get lost.  

jcis7
Pyrite | Level 9

Thank you ! Very helpful!!

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 Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 894 views
  • 3 likes
  • 3 in conversation