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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 644 views
  • 0 likes
  • 2 in conversation