@twocents wrote:
I am trying to run descriptive statistics using PROC MEANS in SAS. However I am getting that my inserted variables are not match type prescribed. Nothing I am doing is working. What am i doing wrong. Also, I get this error for all 14 variables and I am trying to run descriptive statistics on all 14 variables.filename winedata '/folders/myfolders/390 hw/wine.data.txt';data wine;infile winedata DELIMITER=',';input iden $ Alco $ Mali $ Ash $ Alca $ Magn $ Tota $ Flav $ Nonf $ proa $ Colo $ Hue $ OD28 $ Prol $;TITLE 'Wine Summary Data';run;proc print data=wine;run;proc means data=wine n mean;by iden;var iden Alco Mali Ash Alca Magn Tota Flav Nonf proa Colo Hue OD28 Prol;run;
Please use a code box when inserting code, it makes it easier to read and copy/paste. As others have mentioned, the issue is with the $ sign, because that tells SAS to read it in as a character variable. And you can't calculate the mean on a set of characters.
data wine; infile winedata DELIMITER=','; input iden $ Alco Mali Ash Alca Magn Tota Flav Nonf proa Colo Hue OD28 Prol; run; TITLE 'Wine Detail Data'; proc print data=wine; run; TITLE 'Wine Summary Statistics'; proc means data=wine n mean; by iden; *is the data sorted already? If not you may get an error here as well; var iden Alco Mali Ash Alca Magn Tota Flav Nonf proa Colo Hue OD28 Prol; run;
Things in read are ones I've changed or re-ordered.
Make sure you data is sorted, otherwise your BY statement won't work properly.
You cannot take the mean of a character string.
Why did you define the variables as character in your INPUT statement if you want to use them as numbers?
In your imput statement you define all variables as strings. Proc means can only deal with numeric variables. Remove all the $ signs in the input statement and it should hopefully work.
@twocents wrote:
I am trying to run descriptive statistics using PROC MEANS in SAS. However I am getting that my inserted variables are not match type prescribed. Nothing I am doing is working. What am i doing wrong. Also, I get this error for all 14 variables and I am trying to run descriptive statistics on all 14 variables.filename winedata '/folders/myfolders/390 hw/wine.data.txt';data wine;infile winedata DELIMITER=',';input iden $ Alco $ Mali $ Ash $ Alca $ Magn $ Tota $ Flav $ Nonf $ proa $ Colo $ Hue $ OD28 $ Prol $;TITLE 'Wine Summary Data';run;proc print data=wine;run;proc means data=wine n mean;by iden;var iden Alco Mali Ash Alca Magn Tota Flav Nonf proa Colo Hue OD28 Prol;run;
Please use a code box when inserting code, it makes it easier to read and copy/paste. As others have mentioned, the issue is with the $ sign, because that tells SAS to read it in as a character variable. And you can't calculate the mean on a set of characters.
data wine; infile winedata DELIMITER=','; input iden $ Alco Mali Ash Alca Magn Tota Flav Nonf proa Colo Hue OD28 Prol; run; TITLE 'Wine Detail Data'; proc print data=wine; run; TITLE 'Wine Summary Statistics'; proc means data=wine n mean; by iden; *is the data sorted already? If not you may get an error here as well; var iden Alco Mali Ash Alca Magn Tota Flav Nonf proa Colo Hue OD28 Prol; run;
Things in read are ones I've changed or re-ordered.
Make sure you data is sorted, otherwise your BY statement won't work properly.
Thank you so much. I am still learning everything with SAS so I apologize for my formatting.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: