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

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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 2 replies
  • 603 views
  • 3 likes
  • 3 in conversation