The sol2greg
command takes Solar Hijri date variable(s) as input and generates the corresponding Gregorian dates as output(s). sol2greg
supports multiple variable formats (string, numeric, datetime) in both its inputs and outputs.
sol2greg
accommodates three types of Gregorian date inputs:
1. A single string variable in "year/month/day"
format (e.g., "1390/06/01"
) where the command is able to flexibly handle /
, -
, +
, :
, --
, and
(white space) as delimiters.
2. A single variable in one of Stata datetime formats %t*
(e.g., 01sha1390
with underlying value 18862). This is typically the output of greg2sol
command.
3. Three separate variables in year, month, day order. In this case each input variable can be in either string or numeric format.
sol2greg
can generate up to three types of Solar Hijri date outputs:
1. A single variable in "year/month/day"
string format (e.g., "2011/08/23"
).
2. A single variable in Stata datetime format %t*
(e.g., 23aug2011
with underlying value 18862).
3. Three separate variables, one for each of year, month, day values, all in numeric format.
- Suppose the Solar Hijri date value
1390/06/01
is stored in variabledateSolar
(either in string or in Stata datetime format) and one wants to obtain the corresponding Gregorian calendar date2011/08/23
under a new variable calleddateGregorian
in Stata%td
format. The following command does this conversion:
sol2greg dateSolar, datetime(dateGregorian)
- Suppose the Solar Hijri date value
1390/06/01
is stored in three variablesyearSolar
(1390),monthSolar
(6),daySolar
(1), and the corresponding Gregorian date2011/08/23
is to be returned under a single output calleddateGregorian
in string format. The following command does this conversion:
sol2greg yearSolar monthSolar daySolar, string(dateGregorian)
For further examples and more detailed description of use cases refer to test materials or read the accompanying help file of the command.
In order to install sol2greg
, run the following command in Stata:
net install sol2greg, from(https://raw.githubusercontent.com/peymanshahidi/sol2greg/master)
After installation, a comprehensive help file containing detailed description of sol2greg
features along with examples is accessible by typing:
help sol2greg
Reading the help file before using the command is strongly recommended.
The file sol2greg_test.do
in the current repository gives three examples to illustrate different use cases of sol2greg
in Solar Hijri to Gregorian conversion. To test the command follow these steps:
1. Download sol2greg_test.do
from the current repository.
2. Run the script!
The script comprises two parts. The first installs the latest version of sol2greg
and copies a test dataset into your current working direcotry. The second contains three test examples.
If you use sol2greg
in your work, please cite it as below:
Shahidi, Peyman, 2023, "Solar Hijri to Gregorian Calendar Conversion in Stata," GitHub repository, https://github.com/peymanshahidi/sol2greg.
The citation information can be found in the CITATION.bib
file.
Thanks are due to Hosein Joshaghani, who encouraged me to develop this command, and d-learn.ir
, whose historical IRR to USD exchange rate dataset is used in the test materials.
For questions, comments, or feedbacks please contact shahidi.peyman96@gmail.com.