sas >> how to change the variable type?

by agri521@gmail.com » Mon, 09 Jul 2007 19:11:42 GMT

it is need that character type is changed to numeric type. plz how to
make it ? thank.



sas >> how to change the variable type?

by diddy1512 » Mon, 09 Jul 2007 19:59:27 GMT


Hi,

use the INPUT function

new_var=input(old_var, informat.) where informat is the SAS informat that you want to apply to the source.

Best regards,

Ovidiu


it is need that character type is changed to numeric type. plz how to
make it ? thank.



---------------------------------
Got a little couch potato?
Check out fun summer activities for kids.



sas >> how to change the variable type?

by nichas » Mon, 09 Jul 2007 20:19:59 GMT




say .. for example:
char_var is a character variable
I create another variable num_var from char_var
Use the input() function
num_var = input(char_var, informat);

the informat will depend on what is being stored in the char_var
variable.

data one;
char_var = '12sep2006';
num_var = input(char_var,date9.);
run;

num_var will have the date value. You need to apply date* format to
get the num_var in visible date format.



how to change the variable type?

by Barry Schwarz » Tue, 10 Jul 2007 10:56:44 GMT

On Mon, 09 Jul 2007 04:11:42 -0700, " XXXX@XXXXX.COM "



You cannot change the type of a variable.

You can use the input function to convert the value the character
variable represents and assign that converted value to a numeric
variable.


Remove del for email


how to change the variable type?

by G.Q.LEE. » Tue, 10 Jul 2007 14:58:37 GMT

grateful to your help.




how to change the variable type?

by G.Q.LEE. » Tue, 10 Jul 2007 14:59:21 GMT

grateful to you for your help.




Similar Threads

1. how to change the type of existing variable?

2. Change SAS Variable type from Numeric to Character

I am trying to use the Put function to change a numeric variable to a
character variable.

It seems I am having trouble with the format for the original field
because the text field it creates is either centered or has varying
amounts of space to the right.

my code is this:

data two;
   set one;
   acct_nbr_2=put(acct_nbr_1,9.);
run;

The properties for the original field are format 9. and informat 11.

Any help is much appreciated.

3. Using Sql Views to Rename, Order and Change Variable Type

4. Change TYPE to char for all vars?

Hi.

 

Does anyone know the fastest way to set the type of all variables to
CHAR?

 

Thanks

 

Igor Kurbeko

Clinical Programmer Analyst

678 336 4328

 XXXX@XXXXX.COM 

 

Imagination is more important than knowledge

 

5. How to change data type/length in a SAS dataset

6. change a column's data type ?

I want to change a variable from numeric to character.
proc datasets + modify + format can not work. also we can not use
proc sql + alter table to do this.

It seems that the only way for me is to use data step + put function to
generate a new variable of charater type, drop the old one, then rename
the new one.

I want to know if there is a way to directly 'CAST' num to char or vice
versa.

Thanks a lot.

7. reading xls without proc import or changing file type

8. Change variables to variable names

Hi all,

I have an arry which has 90 values in it, the values are something like
ID, Name, Gender, PhoneNumber.........

What I want to do is to use these values as variable names/column names
when I create new dataset. This new dataset should be something like
the following:

ID      Name       Gender    PhoneNumber ..........
 x          y                z                   a

There should be some easy ways to do it than hardcoding, but I just
can't figure it out myself. Please help.

Thanks a lot.