BookmarkSubscribeRSS Feed
knychay
Calcite | Level 5

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.

6 REPLIES 6
TomKari
Onyx | Level 15

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;

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

HerdingDog
Fluorite | Level 6

This doesn't work, like most things I try in SAS. It creates a new empty set with one column. SAS is so freaking tedious. If I didn't have to do this for school, I would never use this software. 

SASKiwi
PROC Star

@HerdingDog - I can understand your frustrations when learning SAS as I had very similar experiences. It's now nearly 40 years since I first learnt SAS and I've never stopped using it in that time. Can you name any other computer languages that are as relevant now as they were back in the 1980's?! And that's quite apart from developing a fascinating career out of it.

 

If you want help with your problem then you need to explain it fully. Posting the SAS log of your code would be a good start. I also suggest you do that in a new post. 

DanielaNRW
Obsidian | Level 7

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.

Tom
Super User Tom
Super User

@DanielaNRW wrote:

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.


This does not make much sense.  The only reason to "open" a dataset would be to check the values so you can plan how you want to analyze it.  Do you mean you are trying to treat your data as if it was in an insecure environment like an Excel Spreadsheet?   

 

To work with your data and derive new information to use in your analysis write a program.  Now you know exactly what you did and can recreate it or explain it to others.

 

To your original issue, if you are reading data from a text file then skip the guessing process and just write your own data step to read the file. Then you have full control over how the variables are defined and how to text into the file is converted into variable in a dataset.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 14106 views
  • 1 like
  • 7 in conversation