• USA : +1 973 910 5725
  • INDIA: +91 905 291 3388
  • info@tekslate.com
  • Login

Analysis and Reporting Procedure: SAS/BASE

Analysis and Reporting Procedure: SAS/BASE

MEANS PROCEDURE: It can be used to generate summary (simple) statistical analysis.

Var Statement: It requires analysis variable. Analysis variable must be numeric var statement is also called analysis statement.

Group variable: It requires grouping variable must variable is also called classification variable .class variable take either character or numeric.

–> Reporting variables in means procedure Nobs, N, mean, std deviation, Minimum, Maximum.

–> Nobs indicates frequency , N- indicates no of non-missing values.

Print all types Option: It can be used to generate all types of analysis based on classification variables and analysis variables.

Eg:         

data market;
input pno Area $ product $ stock sale;
cards;
101         vizag      lux          10           9
109         hyd        lux          16           12
101         hyd        cintool      78           76
110         hyd        cintool      12           10
108         vizag      rin          15           10
108         vizag      lux          15           10
101         vij        lux          23           18
190         hyd        rin          10           9
190         hyd        lux          13           10
190         hyd        rin          14           10
110         hyd        rin          15           12
101         vizag      rin          12           9
145         vizag      lifeboy      13           11
110         vizag      cintool      19           17
101         vizag      lux          13           12
108         vizag      lifeboy      12           11
190         hyd        lifeboy      10           9
101         vij        lifeboy      13           12
110         vizag      lifeboy      12           .
;

/* sales wise analysis */

proc means data = market;
var sale;
run;

/* sales wise analysis based on product*/

proc means data = market;
class product;
var sale;
run;

/* sales wise analysis based on area*/

proc means data = market;
class area;
var sale;
run;

/* All types of analysis */

proc means data = market
printalltypes;
class area product;
var sale;
run;

Output statement: It can be used to store means procedure output in required dataset.

–> If we store the means analysis in data set, SAS system stores in different format use with storage variables.

-STAT-: It indicate statistical keyword.

-FREQ-: It indicates frequency (Nobs)

-TYPE-: It indicates type of analysis used with numbers (0,1,2,3, …..)

proc means data = market
printalltypes;
class area product;
var sale;
Output out = market1
run;

Learn more about SAS Interview Questions in this blog post. Interested in mastering SAS Developer? Check out this blog 
post to learn SAS Training In Hyderabad.
 

/* Create new variable for storage */

proc means data = market
printalltypes;
class area product;
var sale;
Output out = market2
N = sale_N
mean = sale_mean
std = sale_std
maz = sale_maz
min = sale_min;
run;
proc print data = market2;
run;

Class Variable: (2 to the power of class variables): Using this formula. we can report types of analysis.

N, Mean,Median, Max, Min: We can report required analysis.

/* To report analysis for storage and reporting */

Eg:         

proc means data = market
min max;
class product;
var sale;
output out = market;
min = sale_min;
max = sale_max;
run;

maxdec option: It can be used to control decimal places for reporting.

proc means data = market
min max maxdec = 2;
run;

Print Option: Its default woking and generate means analysis in output window. If we don’t want output then we will use noprint option.

Eg:         

proc means data = market noprint;
class area product;
var sale;
Output out = market2;
run;

Nway option: It can be used to report and storage the last grouping analysis.

/* New variable creation for multiple analysis variable */

Eg:         

proc means data = market printalltypes;
class area product;
var stock sale;
Output out = market 3
n = stock_n_sale_n
mean = stock-max sale_mean
max = stock_max sale_max
min= stock-min sale_min
std = stock_std sale_std;
run;

Note: New variable creation can be done based on analysis variables

/*To report total sale of each and every product */

Eg:         

proc means data = market
sum maxdec = 0;
class product;
var stock sale;
run;

If we run the means procedure without any statement it default takes all variables datasets and generate analysis.

Eg:         

proc means data = market;
run;
Internally SAS recognises like this
proc means data = market;
var_numeric_;
run;

– If we run the means procedure using class statement it default run var statement with all numeric variables.

Eg:        

proc means data = market;
class product;
run;
proc means(internally) data = market;
class product;
var_numeric_;
run;


Frequency Procedure: Using with frequency procedure we can do frequency analysis means one-way to N-way analysis and cross tabulation.

– One-way to N-way analysis is called independent analysis and cross tabulation is called dependent analysis.

Eg:         

data one;
input res $ @@;
cards;
y n y n n n y y n n n
;
proc means data = one;
class res;
run;

/* one way analysis */

proc freq data = one;
table res;
run;

Table Statement: It is a analysis statement in frequency procedure. We can use analysis variables either numeric or character.

– Frequency procedure default produce frequency , percent, cumulative frequency, cumulative percent.

/* one way analysis */

proc freq data = one;
table res / no percent;
run;

Options:

Default                                 Change

percent                                    Nopercent                    

freq                                           Nofreq     

row percent                             Norow

column percent                      Nocol                                 

– These all options can be written only in table statement.

Eg:         

data medi;
input group $ week $ drug $ sub;
cards;
G100                      week1                  col5mg                90
G200                      week1                  col5mg                90
G300                      week1                  col5mg                90
G100                      week2                  col5mg                70
G200                      week2                  col10mg               80
G300                      week2                  col10mg               85
G100                      week3                  col15mg               68
G200                      week3                  col10mg               64
G300                      week3                  col15mg               78
G200                      week4                  col15mg               60
G300                      week4                  col5mg                64
  1. No of groups received each drug.
  2. No of groups received drug in each week.

proc freq data = medi;                  proc freq data = medi;

table group rug week;                   table group;

run;                                                   table drug;

table week;

run;

– We can write multiple table statements in frequency procedure.

  1. Total no of sub in each group
  2. Total no of sub received each drug
  3. Total no of sub visited each week.

Weight Statement: It can be used to do column wise sums in frequency procedure.

Eg:         

proc freq data = medi;
table group drug week / nopercent;
weight sub;
run;

Cross Tabulation (dependent analysis):

/* each group taken no of times each drug doses */

Eg:         

proc freq data = medi;
table group * drug / nopercent
No row No col;
run;

/* Total no of sub received ech drug dos in each */ group

proc freq data = medi;
table group * drug / nopercent
No row No col;                       (with missing & non-missing)
weight sub;
run;
Proc means data = medi sum;
class group drug;
var sub;                             (without non-missing values)
run;

/* Each group visited no of times in each week */

Eg:         

proc freq data = medi;
table group * week / nopercent
No row No col;
run;

/* Total no of sub taken drug dose in each fgroup in each week */

Eg:         

proc freq data = medi;
table group * week / nopercent
No row No col;
weight sub;
run;

/* No of groups received each drug dose in each week */

Eg:         

proc freq data = medi;
table drug * week / nopercent
No row No col;
run;

/* Total no of sub received each drug in each week */

Eg:         

proc freq data = medi;
table drug * week / nopercent
No row No col;
weight sub;
run;
- Total no of sub received drug dose in each week --> column        {
- Total no of sub received each drug dose  --> row                        same output
- Total no of groups received each drug dose in each week --> cell     }

/* No of times received each drug dose each group in each week */

Eg:         

proc sort data = medi;
by group;
run;
proc freq data = medi;
table week * drug / nopercent
Norow no col;
by group
run;

/* No of sub received each drug dose each group in each week */

Eg:         

proc sort data = medi;
by group;
run;
proc freq data = medi;
table week * drug / nopercent
Norow no col;
by group;
weight sub;
run;

For indepth knowledge on SAS, click on below

Summary
Review Date
Reviewed Item
Analysis and Reporting Procedure: SAS/BASE
Author Rating
4

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at info@tekslate.com, we will update the article in 24 hours.”

0 Responses on Analysis and Reporting Procedure: SAS/BASE"

    Leave a Message

    Your email address will not be published. Required fields are marked *

    Site Disclaimer, Copyright © 2016 - All Rights Reserved.

    Support


    Please leave a message and we'll get back to you soon.

    I agree to be contacted via e-mail.