BookmarkSubscribeRSS Feed
deleted_user
Not applicable
i am having problem for across report for parent child colmuns.
below is the code. there are two columns Currentatt which is parent and
Attend_Stat which is child. i am getting the values wrong. for each cell the calculation is

(sum of individual cell value /sum of row values )*1000.

piece of code:

Proc Report data=WORK.RuralPerson nocompletecols out=temp missing;
column cnt
sector_cd
('age-group' AgeDesc)
('level of current attendance' Currentatt,(Attend_Stat,(Multiplier Multiplier=mul Sr_Person=mul1))("Total" "" "" Multiplier=all)(Multiplier=all1))
("persons (5-30 yrs.)" "" ("estd.(00)" "" "" Multiplier=all_estpersons)("sample" "" "" Sr_Person=all_samper) SIZE);
define sector_cd / noprint;
define cnt / noprint group ;
define cnt1 / noprint group ;
define AgeDesc / group "" order=data;
define Currentatt / across "" order=data;
define attend_stat / across "" order=data;
define Multiplier / sum "" format=dottozero.;
define all_estpersons / sum "" format=8.;
DEFINE SIZE / COMPUTED NOPRINT;
define all / sum "" format=dottozero.;
DEFINE ALL1/ SUM "" NOPRINT;
DEFINE ALL2/sum "" NOPRINT;
define all_samper / n "" ;
define mul/sum noprint;
define mul1/n noprint;
break after cnt/summarize;
COMPUTE SIZE;
all=SUM(_C4_,_C7_,_C10_,_C13_,_C16_,_C19_,_C22_,_C25_,_C28_,_C31_,_C34_)/all *1000;
_C4_ = _C4_ /ALL1 *1000;
_C7_ = _C7_ /ALL1 *1000;
_C10_ = _C10_ /ALL1 *1000;
_C13_ = _C13_ /ALL1 *1000;
_C16_ = _C16_ /ALL1 *1000;
_C19_ = _C19_ /ALL1 *1000;
_C22_ = _C22_ /ALL1 *1000;
_C25_ = _C25_ /ALL1 *1000;
_C28_ = _C28_ /ALL1 *1000;
_C31_ = _C31_ /ALL1 *1000;
_C34_ = _C34_ /ALL1 *1000;
all_estpersons=all_estpersons/100;
ENDCOMP;

compute after cnt;
AgeDesc='estd. persons(00) (5-30 yrs.)';
_C4_=_C5_/100;
_C7_=_C8_/100;
_C10_=_C11_/100;
_C13_=_C14_/100;
_C16_=_C17_/100;
_C19_=_C20_/100;
_C22_=_C23_/100;
_C25_=_C26_/100;
_C28_=_C29_/100;
_C31_=_C32_/100;
_C34_=_C35_/100;
all=SUM(_C4_,_C7_,_C10_,_C13_,_C16_,_C19_,_C22_,_C25_,_C28_,_C31_,_C34_)/all *1000;
all3=.;
all_estpersons=.;
all_samper=.;
endcomp;

compute after;
AgeDesc='sample persons (5-30 yrs.)';
_C4_ = _C6_;
_C7_ = _C9_;
_C10_ = _C12_;
_C13_ = _C15_;
_C16_ = _C18_;
_C19_ = _C21_;
_C22_ = _C24_;
_C25_ = _C27_;
_C28_ = _C30_;
_C31_ = _C33_;
_C34_ = _C36_;
all=SUM(_C4_,_C7_,_C10_,_C13_,_C16_,_C19_,_C22_,_C25_,_C28_,_C31_,_C34_);
all3=.;
all_estpersons=.;
all_samper=.;
endcomp;
rbreak after / summarize ;
run;

end of code:

kindly give me some solution.
1 REPLY 1
Cynthia_sas
Diamond | Level 26
Hi:
It almost looks to me like you have nesting at several levels in the columns. Since your code is so lengthy and you have to build absolute column names based on the possible combinations of all the ACROSS variables, it's hard to come up with a solution. My suggestion would be to simplify the code back to the place where you were getting correct numbers with one across variable and then introduce a second across variable into the program.

This is exactly the kind of problem that Tech Support is best able to handle. They can take a copy of your code and an example of your data and help you with the correct solution.

Just another thought...have you tried this report with PROC TABULATE??? The syntax for specifying a denominator definition does not require absolute column numbers when you have nested variables in the column dimension.

To contact Tech Support, go to http://support.sas.com/ and in the left-hand navigation pane click on the link entitled, "Submit a Problem".

cynthia

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 1 reply
  • 875 views
  • 0 likes
  • 2 in conversation