BookmarkSubscribeRSS Feed
m231
Calcite | Level 5

Hi all,

 

I am having such a horrible time right now. I imported my own data set from excel from qualtrics and I am getting a bunch of error messages. I noticed that when I click on my data set sas7bdat format, I noticed there is character instead of numeric like the other data sets.

I am also getting ERROR: variable age in list does not match type prescribed for this list.

 

I am trying to run descriptive statistics on age, gender, and race.

 

I appreciate all your help so much!

 

this is my code

libname classdat "/home/u47052435/ClassDat";

proc contents data=group4homelessness;
run;

*Basic descriptive statistics for scale variable "age"
proc means data= classdat.group4homelessness
var age:
run;

*Additional statistics for scale "age";
proc means data=classdat.group4homelessness n mean median mode min max
stddev range qrange nmiss;
var age;
run;

 

4 REPLIES 4
jimbarbour
Meteorite | Level 14

How are you bringing in the Excel data?  There are several ways this might occur:

  1. Via a Libname using the XLSX engine if you have SAS/Access on your machine.
  2. Via a Proc IMPORT
  3. Via SAS Enterprise Guide which has a very nice facility for importing Excel

Enterprise Guide might be the easiest, but all of these can be configured one way or another so that you can specify the data type when you import.  I would delete the data and re-import unless there is an overriding reason not to do so.

 

You could also write a data step to convert things.  It might be easier to just re-import the data though.  Example:

DATA  Reconfigured_Data (RENAME=(Numeric_Var=Old_Var));
    SET  Incorrect_Type_Data;

    Numeric_Var = INPUT(Old_Var, 8.);
RUN;

The trick here is that 8. Informat.  You have to get the right length for your data.  Again, it might be easier to just re-import.

 

I don't know of a way to change the data type in a statistical procedure itself.  You generally need to fix the data before running the Proc.

 

Jim

 

 

m231
Calcite | Level 5

Hi Jim, I am adding the excel file through libname.

I tried generating the code you sent and I am getting ERROR: FILE WORK.INCORRECT_TYPE_DATA.DATA does not exist.

jimbarbour
Meteorite | Level 14

Yes, I just used that as an illustrative name.  You have to change my code to the dataset names.  The same applies to the variables.  You have to substitute the real names for the names I used.

 

Jim

jimbarbour
Meteorite | Level 14

Looking at your code, the real dataset name I think is 

classdat.group4homelessness

and the real variable name is

var age;

 

I was just trying to illustrate a principle.  You still have to do a little work.  🙂

 

JIm

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

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
  • 4 replies
  • 386 views
  • 0 likes
  • 2 in conversation