BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Santt0sh
Lapis Lazuli | Level 10
data xxx;

input grp_cnts Count_grp_cnts Tr_Amt Tdate ;

datalines;

2 45 21000 200910

12 15 51000 200910

11 545 1000 200910

03 248 5000 200910

;

run;



/*creating a report:*/

PROC REPORT DATA = XXX;

COLUMN Tr_Amt  Tr_Amt  = STD_TRNS_AMTS Count_grp_cnts Tr_Amt  = LMT;

DEFINE Tdate/ GROUP;

DEFINE LMT/GROUP ORDER=DATA;

DEFINE Tr_Amt  /ANALYSIS MEAN FORMAT = 20.2 ' AVG_AMT';

DEFINE  STD_TRNS_AMTS / ANALYSIS MEAN FORMAT = 20.2 ' STD_TRNS_AMTS ';

DEFINE  Count_grp_cnts/ ANALYSIS SUM FORMAT = 20.2 ' Count_grp_cnts';

RBREAK AFTER /SUMMARIZE DOL;

DEFINE LMT / COMPUTED 'LTD';

COMPUTE BEFORE LMT;

    LMT = Tr_Amt  + 5 * STD_TRNS_AMTS ;

ENDCOMP;

RUN;

Hi All,

I am trying to create a Report using Proc Report. The details are attached, I am not able to generate the reports because of the 

ERROR: COMPUTED conflicts with earlier use of Tr_Amt 

Kindly suggest me this.

 

Thanks!

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

See this example:

proc report data=temp;
column tdate Count_grp_cnts (sum mean std),tr_amt lmt;
define tdate / group;
define Count_grp_cnts / analysis sum;
define tr_amt / analysis;
define lmt / computed;
compute lmt;
  lmt = tr_amt.mean + 5 * tr_amt.std;
endcomp;
run;

View solution in original post

7 REPLIES 7
Santt0sh
Lapis Lazuli | Level 10

Hi All,

 

I m trying to create a Report using Proc Report by creating computed columns. I m getting another ERROR: You can only BREAK on GROUPing and ORDERing variables.

 

kindly suggest.

 

 

 

 

Santt0sh
Lapis Lazuli | Level 10
Hi Kurt,
Thank you for your quick response!

Since I was not able to upload a new attachment, I am posting the report and the dataset structure below.

The below data set is the source - 2 datasets (Temp and Temp1).
data TEMP;

input grp_cnts Count_grp_cnts Tr_Amt Tdate ;

datalines;

2 45 21000 200910

12 15 51000 200910

11 545 1000 200910

03 248 5000 200910

;

run;


DATASET = TEMP1
Tdate Tr_Amt  grp_cnts Count_grp_cnts 
200910 21000 2 45
200910 51000 12 15
200910 1000 11 545
200910 5000 3 248


The report/dataset should look something like this.
Tdate= for the reporting month
Tr_Amt = Average of Tr_Amt for the Reporting Month
STD_TRNS_AMTS = STDEV of the Average of the Tr Amt for the reporting month.
Count_grp_cnts= Sum of the group counts for the reporting month
LMT is calcluated: LMT = Tr_Amt + 5 * STD_TRNS_AMTS

Tdate Tr_Amt  STD_TRNS_AMTS Count_grp_cnts Tr_Amt  LMT
200910 19500 19665.96044 853 xxxxxxx


Thank you for your Time and Help!!
Santt0sh
Lapis Lazuli | Level 10
Hi Kurt,

Thank you for your quick response!
We need to use the Mean(Average) of Tr_Amt to compute the LTD column.

Thanks

Kurt_Bremser
Super User

See this example:

proc report data=temp;
column tdate Count_grp_cnts (sum mean std),tr_amt lmt;
define tdate / group;
define Count_grp_cnts / analysis sum;
define tr_amt / analysis;
define lmt / computed;
compute lmt;
  lmt = tr_amt.mean + 5 * tr_amt.std;
endcomp;
run;
Santt0sh
Lapis Lazuli | Level 10
Hi Kurt,

Thank you!!
The Code works and is generating the report.


Regards,
Santosh

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
  • 7 replies
  • 664 views
  • 1 like
  • 2 in conversation