BookmarkSubscribeRSS Feed
ccherrub
Obsidian | Level 7

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:
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
68
69 data work.details;
70 keep /*mean method probt Star class*/ income male MeanEdited ColumnName;
71 where male ne "Pooled";
ERROR: No input data sets available for WHERE statement.
9 REPLIES 9
mkeintz
PROC Star

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.

 

 

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
ccherrub
Obsidian | Level 7
Okay so this is what I have as of now:
ods output ConfLimits=MeanVals ttests=PValue ;
proc ttest data=work.details;
Var raceethnic male;
Class male;
run;
quit;

data MergedResults;
set work.details;
merge MeanVals PValue;

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,dollar.2),Star);

length ColumnName $30;
if class="1" then ColumnName="Avg. AHE for Men";
else if class="2" then ColumnName="Avg. AHE for Women";
else ColumnName="Diff. in Avg. AHE";
run;

proc print data=MergedResults;
run;

And heres' the prompt for the best context:
"...should have one row for each race and columns should be the average income
for men, average income for women, and the difference in average income. In the last column, in addition to the size of the difference in average income, you should include the result of a t-test (i.e., Proc TTest) that checks whether the difference in average income between men and women of any given race is statistically significant. Use the “star” system to report the result of your test."

**Also to note race and gender are numerical categories if that changes anything
tarheel13
Rhodochrosite | Level 12
Your proc ttest does not look correct. What is the income variable called?
ccherrub
Obsidian | Level 7
It's just called income if interpretted your question right
tarheel13
Rhodochrosite | Level 12

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? 

tarheel13
Rhodochrosite | Level 12
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. 

ccherrub
Obsidian | Level 7

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 

tarheel13
Rhodochrosite | Level 12

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. 

tarheel13
Rhodochrosite | Level 12

you need to specify the input dataset. 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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
  • 9 replies
  • 1576 views
  • 1 like
  • 3 in conversation