BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi
I got customer data for 24 months and their booking data. i need to find their volatility based on their median as follows processor . i been asked

Summarise data to partner, month, booknet (table1)

2. Calculate median booknet for each customer

3. Create a table containing customer, booknet_median (table2)

4. Merge table1 and table 2 (into table3), create fields

a. ‘vola’ = booknet/booknet_median*100,

b. vola_75_125 = if index between 75 and 125 then 1 else 0

5. Summarise table3 by customer, sum vola_75_125 (table 4)

6. Calculate volatility as sum vola_75_125/24%

so for i used proc summey an d i am stucked at ' a' can any one help me out

Thanks,
chand
1 REPLY 1
Cynthia_sas
SAS Super FREQ
Hi:
This is not really an ODS or Base Reporting procedure (PRINT, REPORT, TABULATE) question. Although, 5 could be done by any of the above procedures; report 6 probably is best done with PROC REPORT.

You can either create your fields as part of the merge that creates table 3 or in a separate query, after table 3 is created.

Then, once that you have table 3, you can work on the report tasks 5 . Here's an example of a few reports using sashelp.shoes:

[pre]
ods listing;
proc print data=sashelp.shoes noobs n;
title '5) Detail Listing with Sum';
by region;
var region product sales;
sum sales;
run;

proc tabulate data=sashelp.shoes f=8.2;
title '5) Summary Report with Grand Total and Percents';
class region product;
var sales returns;
table region all, n pctn;
table product all, n pctn;
table region all, sales* (n pctn sum*f=comma12. pctsum);
table product all, sales* (n pctn sum*f=comma12. pctsum);
run;
[/pre]

#6 doesn't exactly look like a report -- but maybe it is. It looks like you only want the calculation to be done on the 0/1 field that you set in b. Here's a possible solution using a DATA step and PROC REPORT:
[pre]
data calcvar;
set sashelp.shoes;
where product in ('Slipper', 'Sandal', 'Boot');
if product = 'Slipper' then numvar = 0;
else if product = 'Boot' then numvar = 0;
else numvar = 1;
run;

proc report data=calcvar nowd;
title '6) One Possible Solution';
where product in ('Slipper', 'Sandal', 'Boot');
column region product sales inventory numvar ;
define region / group;
define product / group;
define sales / sum;
define inventory / sum;
define numvar / sum;
break after region / summarize skip;
compute after region;
divnum = numvar.sum / .24;
line 'The number is: ' divnum comma8.2;
endcomp;
run;
[/pre]

For further help, you might consider looking at the SAS documentation or contacting Tech Support.

cynthia

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 1253 views
  • 0 likes
  • 2 in conversation