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
SAS Super FREQ
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

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 547 views
  • 0 likes
  • 2 in conversation