Desktop productivity for business analysts and programmers

How do I change the data type in an imported table

Reply
N/A
Posts: 1

How do I change the data type in an imported table

I just imported comma delimited data into SAS Enterprise Guide using the Import Data wizard. One of the fields defaulted to numeric and I should have changed it to Character but didn't. Now that the table has already been imported, is there a way of changing the field type? I tried right clicking the table and selecting Properties but that didn't work. I also tried opening the table, selecting the column I want to change, right-clicking, and selecting Properties. That brought up what appears to be the correct dialog box, but the drop down menu for Type is greyed out and won't allow me to make the change.

Trusted Advisor
Posts: 1,050

Re: How do I change the data type in an imported table

You'll need to copy your dataset, and move your column into a new column. Something like this;

data want;

set have(rename=(NeededVar = OldNeededVar));

length NeededVar $15;

NeededVar = input(OldNeededVar, best15.);

drop OldNeededVar;

run;

Esteemed Advisor
Esteemed Advisor
Posts: 7,190

Re: How do I change the data type in an imported table

Just to note Tom, your code will pop a note in the log for conversion.  Your better off using the put(OldNeededVar,best15.).

For the OP - fix your import.  I.e. take the generated code from the proc import (I don't use EG, so can't help where it would be - maybe there is a checkbox or something), and modify it to properly import the data - note you don't mention the file import format, but I assume Excel as this is the one that causes most problems.  Switch to CSV and write a datastep import program which gives you full control over the import.

Occasional Contributor
Posts: 13

Re: How do I change the data type in an imported table

When you open datasets you cannot change values or the data type because of read access. If you try to change a value a popup window opens and asks if you want to switch to update mode. Now you can change the properties of the column and the drop down menu for Type is not greyed out any more.

Ask a Question
Discussion stats
  • 3 replies
  • 2009 views
  • 1 like
  • 4 in conversation