Help using Base SAS procedures

PROC FORMAT

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 14
Accepted Solution

PROC FORMAT

Hi,

How can I delete fist zero in variable ID_var it is charecter variable.

 

This is i have

IDDPLID_var
1233964309980000000010000100
1234531323310000000010006377
1237805397910000000010042044
140434413280000000010049190

This I want

IDD

PL

ID_var

1233964

30998

10000100

1234531

32331

10006377

1237805

39791

10042044

140434

41328

10049190

Does anybody know?


Accepted Solutions
Solution
‎07-07-2017 08:04 AM
Super User
Posts: 7,854

Re: PROC FORMAT

Posted in reply to jopo12345678
data test;
id_var = "0000000010000100";
id_var = left(put(input(id_var,32.),best32.));
run;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Solution
‎07-07-2017 08:04 AM
Super User
Posts: 7,854

Re: PROC FORMAT

Posted in reply to jopo12345678
data test;
id_var = "0000000010000100";
id_var = left(put(input(id_var,32.),best32.));
run;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Regular Contributor
Posts: 191

Re: PROC FORMAT

[ Edited ]
Posted in reply to jopo12345678

Try this:

data test;

length id_var $32;

input id_var;

id_var = strip(put(input(id_var,32.),32.));

datalines;

0000000010000100

0000000010006377

0000000010042044

0000000010049190

;

run;

Occasional Contributor
Posts: 14

Re: PROC FORMAT

I would like to change it to numeric variable without datalines statement.

Super User
Posts: 7,854

Re: PROC FORMAT

Posted in reply to jopo12345678
data want;
set have (rename=(id_var=id_char));
id_var = input(id_char,32.);
drop id_char;
run;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
PROC Star
Posts: 326

Re: PROC FORMAT

Posted in reply to jopo12345678
Occasional Contributor
Posts: 14

Re: PROC FORMAT

Posted in reply to jopo12345678

I would like to change it to numeric variable...is there any option?

☑ This topic is solved.

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

Discussion stats
  • 6 replies
  • 260 views
  • 1 like
  • 4 in conversation