DATA Step, Macro, Functions and more

convert the integer into decimal.

Reply
Occasional Contributor Uli
Occasional Contributor
Posts: 8

convert the integer into decimal.

Dear All,

Please help me out the following issue.
Input:

data a;
input a ;
datalines;
9
34
45
64
;

output;

9.00
34.0
45.0
64.0

I can convert the data using put function to character (ex: put(a,8.1);
or i can display the value with format 8.1;

I just want to store the value with decimal value Zero to the integers ( i.e 34 to 34.0)


Could you please suggest me is ther any other way to solve this issue.

Thanks In Advance.



Please help me out
Respected Advisor
Posts: 4,173

Re: convert the integer into decimal.

Hi

SAS knows only 2 data types: character or numeric. There is no integer data type.

But you can always store a format like 8.1 permanent for a variable - so it will show 34.0 by "default".

HTH
Patrick
Occasional Contributor Uli
Occasional Contributor
Posts: 8

Re: convert the integer into decimal.

Dear Patrick.

Thanks for your response.

How can i convert numeric value 34 to 34.0 and stores into numeric variable.

Thanks IN Advance.
Super Contributor
Posts: 578

Re: convert the integer into decimal.

From SAS' perspective, there is no difference between 34 and 34.0 except for the display format. The underlying data are the same.

If you want to change the format, then you can do so but it makes zero difference with the actual data.
Super Contributor
Super Contributor
Posts: 3,174

Re: convert the integer into decimal.

More specific to the point, review the use of the SAS FORMAT and/or ATTRIB statement which is used to associate an "output display format" with a SAS variable.

There are both SAS-system standard formats documented in the SAS Language Dictionary and also there is the SAS PROC FORMAT (procedure) where you can develop / define your own format.

Scott Barry

Suggested Google advanced search arguments, this topic / post:

display numeric variable integer decimal site:sas.com

format documentation site:sas.com
Ask a Question
Discussion stats
  • 4 replies
  • 4431 views
  • 0 likes
  • 4 in conversation