BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Alexxxxxxx
Pyrite | Level 9

hello,

 

Do you know how to fill value with zero and reach a tens digit?

for table have

 

have
CIK
915913
1029506
3673
75677
0001091530

I expect to get table want

want
CIK
0000915913
0001029506
0000003673
0000075677
0001091530

 

thanks in davance.

data table1;
  infile cards truncover;
  input
    CIK $100.
  ;
  cards;
915913
1029506
3673
75677
0001091530
;
1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Use the Z. format.

cik = put( input(cik, 10.), z10.) ;
 
 
 
--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

Use the Z. format.

cik = put( input(cik, 10.), z10.) ;
 
 
 
--
Paige Miller
mkeintz
PROC Star

@Alexxxxxxx wrote:

hello,

 

Do you know how to fill value with zero and reach a tens digit?

for table have

 

have
CIK
915913
1029506
3673
75677
0001091530

I expect to get table want

want
CIK
0000915913
0001029506
0000003673
0000075677
0001091530

 

thanks in davance.

data table1;
  infile cards truncover;
  input
    CIK $100.
  ;
  cards;
915913
1029506
3673
75677
0001091530
;

 

You have just shown why CIK  (central index key from the SEC I presume) should always be treated a a character variable.

 

Try this (I replaced your $100. with $10.):

 

data table1;
  infile cards truncover;
input cik $10. cik=translate(right(cik),'0',' '); cards; 915913 1029506 3673 75677 0001091530 ;

 

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1090 views
  • 3 likes
  • 3 in conversation