I'm not sure exactly what the process is called but here is my code:
data work.details;
keep /*mean method probt Star class*/ income male MeanEdited ColumnName;
where male ne "Pooled";
length Star $3;
if probt=. then Star="";
else if Probt le 0.01 then Star="***";
else if probt le 0.05 then Star="**";
else if probt le 0.1 then Star="*";
else Star="";
format Mean dollar.2;
MeanEdited=Cats(put(mean,dollar10.2),Star);
length ColumnName $30;
if class="1" then ColumnName="Avg. Income for Men";
else if class="0" then ColumnName="Avg. Income for Women";
else ColumnName="Diff. in Income. AHE";
run;
And the error I keep getting:
Where is the source of your data? The DATA step code you show suggests that you want to create work.details, but does not tell SAS where to get the data from. In your DATA step, that would probably be done via a SET statement.
so if you're looking for average income then the var statement in proc ttest needs to say var income. can you post your data as datelines?
ods trace on;
ods output ttests=pvalue statistics=means;
proc ttest data=dmvs;
by race;
class sex;
var vsstresn;
run;
ods trace off;
data pvalue;
set pvalue;
where method='Pooled';
run;
data means2;
set means;
if method ne 'Satterthwaite';
if class='Diff (1-2)' then classn=3;
else if class='M' then classn=1;
else if class='F' then classn=2;
run;
proc sort data=means2;
by race classn;
run;
proc transpose data=means2 out=means_t prefix=c;
by race;
id classn;
var mean;
run;
proc sort data=means_t;
by race;
run;
proc sort data=pvalue;
by race;
run;
data merged;
merge means_t pvalue;
by race;
if probt >=0 and probt <=.001 then sig="***";
else if probt >.001 and probt <=.01 then sig='**';
else if probt >.01 and probt <=.05 then sig='*';
else if probt >.05 and probt <=0.1 then sig='.';
else if probt >.1 and probt <=1 then sig='';
p=put(probt,pvalue.);
run;
proc report data=merged;
columns race c1 c2 c3 p sig;
define race / "Race";
define c1 / "Avg. Male Income";
define c2 / "Avg. Female Income";
define c3 / "Avg. Diff";
define probt / "P-value";
define sig / "Sig.";
run;
something like that should work but again we have not seen your data.
So here's the code under the data:
PROC SQL;
CREATE TABLE WORK.query AS
SELECT 'year'n , id , statefips , male , raceethnic , ed , marst , nchild , occ , ind , wkswork , age , income FROM _TEMP0.db1;
RUN;
QUIT;
PROC DATASETS NOLIST NODETAILS;
CONTENTS DATA=WORK.query OUT=WORK.details;
RUN;
PROC PRINT DATA=WORK.details;
RUN;
data work.details;
set work.query (drop='year'n);
run;
Attached is what the data looks like
ok I still don't think your proc ttest is correct. the var needs to say income. you are looking for to see if males and females had different means within a race.
you need to specify the input dataset.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.