BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. 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 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 1235 views
  • 1 like
  • 2 in conversation