0% found this document useful (0 votes)
176 views

Proc Freq Run Proc Freq Run Proc Freq Run Proc Freq Run Proc Freq Run Proc Freq

The document contains SAS code that performs various statistical analyses on a candy sales dataset. It includes procedures to generate frequency tables, calculate descriptive statistics, create means and sums by subgroups, sort the output, and extract date fields and calculate differences between dates. The analyses are conducted to understand the characteristics and relationships within the candy sales data.

Uploaded by

Soumi Banerjee
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
176 views

Proc Freq Run Proc Freq Run Proc Freq Run Proc Freq Run Proc Freq Run Proc Freq

The document contains SAS code that performs various statistical analyses on a candy sales dataset. It includes procedures to generate frequency tables, calculate descriptive statistics, create means and sums by subgroups, sort the output, and extract date fields and calculate differences between dates. The analyses are conducted to understand the characteristics and relationships within the candy sales data.

Uploaded by

Soumi Banerjee
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

proc freq data=day1.

candy_sales_summary;
tables subcategory category;
run;
proc freq data=day1.candy_sales_summary;
tables _all_;
run;
proc freq data=day1.candy_sales_summary;
tables _character_;
run;
proc freq data=day1.candy_sales_summary;
tables subcategory * category;
run;
proc freq data=day1.candy_sales_summary;
tables subcategory * category/norow nocol nopercent;
run;
proc freq data=day1.candy_sales_summary;
tables fiscal_year* subcategory * category/norow nocol nopercent;
where fiscal_year in('2000','2003');
run;
proc means data=day1.candy_sales_summary n nmiss std skewness kurtosis max min
sum maxdec=2;
var sale_amount;
run;
proc means data=day1.candy_sales_summary sum maxdec=2;
var sale_amount;
class subcategory;
run;
proc means data=day1.candy_sales_summary mean sum maxdec=2;
var sale_amount;
class subcategory;
output out=day1.candy_sales_means sum=total_sales mean=avg_sales;
run;
proc means data=day1.candy_sales_summary mean sum maxdec=2 noprint;
var sale_amount;
class subcategory category;
output out=day1.candy_sales_means2 sum=total_sales mean=avg_sales;
run;
data day1.candy_sales_means2;
set day1.candy_sales_means2;
if _TYPE_ ^= 3 then delete;
run;
proc sort data=day1.candy_sales_means2 out=day1.candy_sales_means_sort;
by descending total_sales;
run;
/*proc sort uses ascending order by default*/
proc summary data=day1.candy_sales_summary print;
var sale_amount;/*in absence of this statement we get only # obs*/
run;
/*proc means is a print output and by default proc summary is no print
output*/
proc univariate data=day1.candy_sales_summary;
var sale_amount;
run;

/*SAS functions*/
/*Date functions*/
/*Date functions - day,month,year, mdy,
today(),weekday,qtr,datdif,yrdif,intck,datetime(),datepart*/
/*date9.-->01jan2009*/
data day1.candy_date;
set day1.candy_sales_summary;
day=day(date);
/*Syntax:newvar=function(existing var)*/
month=month(date);
year=year(date);
Weekday=weekday(date);/*1=sunday*/
quarter=qtr(date);
new_date=mdy(month,day,year);
format new_date date9. Curr_date date9. date_part date9.;
Curr_date=today();/* gives system date in sas format by default*/
Date_diff=datdif(new_date,Curr_date,'ACT/ACT');/*date_diff=datdif(start_di,end
_dif,'basis')*/
date_diff_=datdif(new_date,Curr_date,'30/360');
Year_diff=yrdif(new_date,Curr_date,'ACT/ACT');
Year_diff2=yrdif(new_date,Curr_date,'ACT/360');
month_diff_intck=intck('month',new_date,Curr_date);
day_diff_intck=intck('day',new_date,Curr_date);
Year_diff_intck=intck('year',new_date,Curr_date);
date_time=datetime();
date_part=datepart(date_time);
run;

You might also like