Hello,
I want to change the format of a variable to numeric
the actual format and informat is $28.
data IPO_list0;
set IPO_list0;
Asset_alloc_equity_net1 = input(Asset_alloc_equity_net, 8.);
run;
Hello,
I want to change the format of a variable to numeric
the actual format and informat is $28.
To change the type of a variable, you have to create a new one, convert the value with the INPUT function, drop the old variable, and rename the new one to the name of the old.
can you please give an example of numeric format
I know that I should write
data want;
set have;
format var ;
informat var;
run;
After 160+ posts here, it should be a breeze for you to write the code from my description.
Do that, and if you run into problems, post example data in usable form, and the complete log you got from the code you tried.
@sasphd wrote:
Hello,
I want to change the format of a variable to numeric
the actual format and informat is $28.
Please provide example values.
If a character variable holds 28 digits it can very well run into issues with computer precision when stored as numeric.
The largest integer values that can be stored reliably in SAS are below, first for Z/OS and second for Windows/UNIX flavors. Note that neither of these comes anywhere near 28 characters even with the commas, which are not part of the value.
72,057,594,037,927,936
|
9,007,199,254,740,992
|
Are you going to do arithmetic with the values? If not then they should remain character. If you will then you may have significant issues with computation and precision.
data IPO_list0;
set IPO_list0;
Asset_alloc_equity_net1 = input(Asset_alloc_equity_net, 8.);
run;
And now you add a little code:
data IPO_list0 (
drop=Asset_alloc_equity_net
rename=(Asset_alloc_equity_net1=Asset_alloc_equity_net)
);
set IPO_list0;
Asset_alloc_equity_net1 = input(Asset_alloc_equity_net, 8.);
run;
and you have effectively changed the type of the variable.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: