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

st: RE: RE: syntax question

From   "David Moore" <>
Subject   st: RE: RE: syntax question
Date   Tue, 19 Nov 2002 10:20:10 -0800

Nick has correctly guessed the Stata idiom for converting most of the
illustrated SAS programming constructs.  One problem, however, is that SAS
allows variable arrays and I believe these still do not exist in Stata.  You
can program around this, of course, but that's not a simple matter of
converting from one language to another.  Those with Stata 7 will benefit
from the "new" looping commands.  Those of us who still can't afford to
upgrade must resort to -while- loops.

-----Original Message-----
[]On Behalf Of Nick Cox
Sent: Tuesday, November 19, 2002 5:40 AM
Subject: st: RE: syntax question
> Hi Stata users, I'm now trying to convert SAS language to
> Stata. Since I'm relatively new to Stata, any help will be
> greatly appreciated!!!!
> The SAS language I try to rewrite for Stata is
> do i =1 to 6;
>    if (ICAT EQ i) then do;
>       do j =1 to 4;
>             if (KiAj{j,1} > 0) and (KiGj{j,1} > 0) then do;
>             IGC{i}   =IGC{i}   + KiGj{j,1};
>             IGC_h{i} =IGC_h{i} + KiAj{j,1};
>             IHC{i}   =IHC{i}   + KiHj{j,1};
>          end;

What is SAS? Or more seriously, I don't know SAS,
so I am guessing.

do seems to map to -forvalues-. There is a tutorial
on -forvalues- -- for which you need to know the
rudiments of local macros -- at

EQ presumably is a test for equality so that is ==.

The main pitfall to be aware is the difference in Stata
between the -if- command and the -if- qualifier.



*   For searches and help try:

*   For searches and help try:

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