Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: statalist-digest V4 #1083


From   "Ssu Weng" <[email protected]>
To   <[email protected]>
Subject   st: Re: statalist-digest V4 #1083
Date   Fri, 29 Nov 2002 13:35:01 -0700

1. re: if...then...else
This is how I would write code for the variable score
(I'm changing your example to a numeric variable because I am uncomfortable
with char types):

 g byte grade  =1 if score > 90 /*now any score<=90 is .*/
recode grade .=2 if score > 80 /*now any score<=80 is ., and so forth*/
recode grade .=3 if score > 70
recode grade .=4 if score > 60
label def grade 1 A 2 B 3 C 4 D
label val grade grade
-----------------------------------
original question from Richard Herrell <[email protected]>
Say I want to assign grades to my
students' percentage scores.  In SAS I could write

if      score > 90 then grade='A';
else if score > 80 then grade='B';
else if score > 70 then grade='C';
else if score > 60 then grade='D';
************************************
2.  advantages of SAS/SUDAAN but not in Stata
For survey data, SAS/SUDAAN can do survival analysis.
Also, SAS/SUDAAN is easier to use when I need to do survey data cross-tabs
(equivalent of svymean or svytab) & then output results into a text file.
Jan Brogger has a macro to do this for the estimated percents, but I have
not successfully written a program for my needs, as I have trouble accessing
estimates from matrices (I am not a programmer).

In SAS/SUDAAN, I can cross-tabulate survey data with SUDAAN, then use SAS to
create one row of delimited text file for each combination of values of the
x-variable and y-variable (I can specify that I want the rows sorted first
by y-variable, then by x-variable):  each of these rows contains the
estimated row percent (from weighted data, using design variables), standard
error of estimated percent, lower 95%CL of weighted percent, upper 95%CL of
weighted percent, sample number, estimated number, standard error of
estimated number, lower 95%CL of estimated number, upper 95%CL of estimated
number.  [Or I could do this for column percents & estimated numbers, or
just the percents, or just the numbers].  This enables me to create Excel
files with hundreds of cross-tabs in relatively short time.

If anyone has a program that is ready-to-use for this purpose, I would be
most grateful.

Ssu Weng
Epidemiologist
Maternal and Child Health Epidemiology
New Mexico Department of Health
Santa Fe, NM 87505
[email protected]
home phone 505 983 3168
office phone 505 476 8892

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index