Hi,
This is my code.
/* NATIONAL Abor*/
proc report data=work.WFA
nowd;
columns EEOG NOC CMA PRI Abor Aborprc LMAAbor Expected Gap;
define EEOG / group 'EEOG' left;
define NOC/ group 'NOC' left;
define CMA / group 'CMA' left;
define PRI/ analysis n format=comma8. '# of Employees ' center;
define Abor/analysis n format=comma8. '# of Abor' center;
define Aborprc / computed format=percent8.1 'Abor(%)'center;
compute Aborprc;
AborPRC= Abor.n/PRI.n;
endcomp;
rbreak after / dol skip summarize style=Header{fontweight=bold};
compute after;
EEOG= "Total";
endcomp;
run;
EEOG has different values, I want to customize my code to drop certain variables based on each EEOG. For example, if EEOG is 2, I want to drop NOC and CMA, but if EEOG is 3, I only want to drop CMA.
is there any way of coding this?
Thanks,
Nazanin
You can't conditionally 'drop' variables. You can set it to missing, but I would recommend doing that in a previous step. Not 100% sure this will give you want you want. If not, post back more details, specifically an example of what you're getting and what you want instead.
data wfa2;
set wfa;
if eeog=2 then call missing(noc, cma);
if eeog=3 then call missing(cma);
run;
@NazaninSAS wrote:
Hi,
This is my code.
/* NATIONAL Abor*/
proc report data=work.WFA
nowd;
columns EEOG NOC CMA PRI Abor Aborprc LMAAbor Expected Gap;
define EEOG / group 'EEOG' left;
define NOC/ group 'NOC' left;
define CMA / group 'CMA' left;
define PRI/ analysis n format=comma8. '# of Employees ' center;
define Abor/analysis n format=comma8. '# of Abor' center;
define Aborprc / computed format=percent8.1 'Abor(%)'center;
compute Aborprc;
AborPRC= Abor.n/PRI.n;
endcomp;
rbreak after / dol skip summarize style=Header{fontweight=bold};
compute after;
EEOG= "Total";
endcomp;
run;
EEOG has different values, I want to customize my code to drop certain variables based on each EEOG. For example, if EEOG is 2, I want to drop NOC and CMA, but if EEOG is 3, I only want to drop CMA.
is there any way of coding this?
Thanks,
Nazanin
Thanks Reeza,
basically, I want o run the code and in the output, I want to drop columns based on EEOG
these are my columns for the whole report:
columns EEOG NOC CMA PRI Abor Aborprc;
but based on the table below, I don't need to see NOC or CMA for EEOG02. or for EEOG 03, I just want the breakdown by NOC. and so on.
EEOG | NOC | CMA | # of Employees | # of Abor | Abor(%) |
2 | No | No | |||
3 | Yes | No | |||
5 | No | yes |
another way I think is writing different codes for different EEOGs and then append them together to have the total.
Thanks,
Nazanin
something like this:
EEOG | NOC | CMA | # of Employees | # of Abor | Abor(%) |
2 | 213 | 20 | 1.4% | ||
3 | 1111 | 1 | 6.7% | 1.3% | |
1112 | 2 | 0 | 0.0% | ||
1114 | 7 | 0 | 0.0% | ||
1121 | 11 | 0 | 0.0% | ||
5 | Winnipeg | ||||
TOTAL | 42,102 | 1,343 | 3.2% |
For EEOG 02, I don not need any further breakdown, but for EEOG o3, I want the breakdown by NOC, EEOG05, I want the breakdown by CMA.
Thanks,
Nazanin
Hi,
I did call missing:
data WFA2;
set WFA;
if EEOG=2 then call missing(NOC,CMA);
if EEOG=3 then call missing(CMA);
if EEOG=5 then call missing ( NOC);
run;
but my output, totally eliminated EEOG02, 03, and 05.
I want o keep them , but I don't want to see NOC and CMA for them.
Thanks,
Nazanin
/* NATIONAL Abor*/
proc report data=work.WFA
nowd;
columns EEOG NOC CMA PRI Abor Aborprc ;
define EEOG / group 'EEOG' left;
define NOC/ group;
define CMA/ group;
define PRI/ analysis n format=comma8. '# of Employees ' center;
define Abor/analysis n format=comma8. '# of Abor' center;
define Aborprc / computed format=percent8.1 'Abor(%)'center;
compute Aborprc;
AborPRC= Abor.n/PRI.n;
endcomp;
compute Expected;
compute after;
EEOG= "Total";
endcomp;
compute after EEOG;
line '';
endcomp;
break after EEOG / dol skip summarize style=Header{fontweight=bold};
footnote "Source, CAS";
run;
just out of curiosity, can I write a "compute" to call another "proc report" ?
Thanks,
Nazanin
no,
I did it to the new one. I also went and changed the data set manually to see if it worked. but as soon as I delete them, the whole EEOG does not show up in the output.
I will run it again, and I will let you know.
Thanks,
Nazanin
Thanks Reeza,
Finally, I found it! I have to use "call missing" as you said before the proc report, but in proc report, when I define variables, I have to use " group" "missing" instead of just "group".
for example:
define NOC/ group missing;
but before I use:
define NOC/ group;
best regards,
Nazanin
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: