Help using Base SAS procedures

SAS 9.3 proc means problem

Reply
Frequent Contributor
Posts: 82

SAS 9.3 proc means problem

roblem problemproc
I have a variable with 3 classes and n = 75. Proc means and proc freq all count n=85. What is the problem.

Thanks

Super User
Posts: 11,343

Re: SAS 9.3 proc means problem

Are you using weights or a freq variable?

Examples of code used might allow us more insight into possible issues.

Frequent Contributor
Posts: 82

Re: SAS 9.3 proc means problem

it is a simple categorical variable,  n=75, 3 classes. Results
showed Frequency missing =10.

The FREQ Procedure
flowblr1
flowblr1FrequencyPercentCumulativeCumulative
FrequencyPercent
borderline15201520
low9122432
normal516875100
Frequency
  Missing = 10

Super User
Posts: 19,784

Re: SAS 9.3 proc means problem

Can you show the code?

If you imported this from an Excel file, you may have accidentally imported some empty rows.

Run a proc contents on the dataset to see what shows up.

proc contents data=have;

run;

Frequent Contributor
Posts: 82

Re: SAS 9.3 proc means problem

It is an excel file. Here is the code to access data sheet:

PROCIMPORT OUT=
WORK.BASELINE

     DATAFILE="f:\V.xls"

     DBMS=EXCEL REPLACE

  SHEET="Sheet11$";

  GETNAMES=YES;

  MIXED=NO;

   SCANTEXT=YES;

  SEDATE=YES;

SCANTIME=YES;

RUN;

Super User
Posts: 19,784

Re: SAS 9.3 proc means problem

Did you run the proc contents? Have you opened the data set to verify how many observations were imported?

Frequent Contributor
Posts: 82

Re: SAS 9.3 proc means problem


data set showed 75 subjects. it is really strange.

thanks

Super User
Posts: 19,784

Re: SAS 9.3 proc means problem

Show the proc contents output?

Trusted Advisor
Posts: 1,228

Re: SAS 9.3 proc means problem

Try this and you will get the correct numbers. In excel file you deleted some of the data points (10) and these were imported as part of sas dataset.

proc freq data=have (where=(flowblr1 ne ' '));

table flowblr1;

run;

Frequent Contributor
Posts: 82

Re: SAS 9.3 proc means problem

Thanks so much.

Super User
Posts: 19,784

Re: SAS 9.3 proc means problem

That's not a good solution. You should make sure your data imports correctly instead and/or clean up the data before processing.

Trusted Advisor
Posts: 1,228

Re: SAS 9.3 proc means problem

Thanks for the input Reeza. That is true, data should be cleaned before processing. Could you please recommend some solution to exclude missing values while importing excel data into SAS or through some other method?

Regards,

Super User
Posts: 19,784

Re: SAS 9.3 proc means problem

Clean it up manually. The problem with the method below is that you may have valid missing obs, so you need to understand the data.

data clean_input;

     set have;

if missing(flowblr1) then delete;

run;

Trusted Advisor
Posts: 1,228

Re: SAS 9.3 proc means problem

Thanks Reeza - This works if we understand our data. But when we load data from other applications we are not sure about data structures and we may get missing values at the end of variable(s) which are hard to identify.  So processing data after loading into SAS will make the life easier.

Super Contributor
Posts: 334

Re: SAS 9.3 proc means problem

I know one way that I have found that works is to use excel libname engine (if you have it available). I can run the libname, see how sas is seeing the excel file, then use a data step to bring the file into sas with any cleaning done in the data step. In instances where missing is valid in all fields, I have wrote an array to check across all fields before deleting -- obviously a much bigger pain the larger the dataset.

libname in excel "\excelfile.xlsx";

data out;

     drop f_20 - f_25; *blank column / field clean up;

     set in."Sheet1"n;

     if id = '' then delete; *row clean up -- works as long as id always suppose to have a value;

run;

libname in clear;

Just an added opinion!

EJ

Ask a Question
Discussion stats
  • 18 replies
  • 555 views
  • 2 likes
  • 7 in conversation