SAMPLE MACROS:
DOWNLOADS FOR MORE THAN ONE SERIES
1. download.mac
download.mac
Use this macro to download data when you only need to retrieve the values associated with your various codes. The download macro is useful for gathering economics data (Program 150Z), interest rates (Help IR?), stock indices returns (HELP SI?), etc.
Entering the Macro:

It is important that you save the macro as a CSV file so that you can open the data in Microsoft Excel, Stata, and SAS. If you do not have a floppy disk with you, save the file to the hard drive and then FTP the document to your Unix account. Files left on SSRC computers will be erased.

NOTE: If you want your data to run until the present, do not include an ending date and simply leave the two commas following the starting date.
After the commas, enter the frequency for which you want the data. Note the following frequency codes:
Daily = D
Weekly = W
Monthly = M
Quarterly = Q
Yearly = Y
5. After TESTLIST:
DATA
Enter your mnemonic. Enter the code exactly as it appeared on the Datastream screen. Surround the mnemonic with quotation marks, followed by a comma outside of the quotation marks.



datatype.mac
The macro below is similar to the download.mac, except for the two-letter extension in the "program" line. This is the datatype code for the program and enables you to retrieve data beyond that supplied by the program and beyond that supplied by the default. Frequently, this is used in the equities program to obtain something other than the default, such as the Price Index.
You may also use the download.mac simply by augmenting each code with the datatype abbreviation in parentheses: U:IBM(DY). In this example, the macro will retrieve the dividend yield for IBM, Microsoft, and other stocks. But, when there are many codes, it is easier to use the datatype.mac, rather than entering (DY) after every code.


NOTE: The datatype macro can also be used to retrieve other information, including market value (MV) and return index (RI).
After entering the macro, click on File and then select Save.
Return to the main Datastream screen (if it is not on the main screen, press CLEAR. The macro will not run if Datastream is not on the original screen. Select Macro from the top of the screen and the click on Run macro… Select datatype.mac from the choices on the left and then click OK. This should enable the program to start.
NOTE: For images of the above steps, see the download.mac tutorial at the top of this page.
list900a.mac
This macro combines the basic data-retrieving commands of the download macro, but adds list-making commands. The macro instructs Datastream to create a list; for each code on that list. Datastream then retrieves the data, just as it does in the download.mac
Use the list900A.mac for codes you have obtained from the Equity Lists (HELP EQLI?).

NOTE: It is important that you save the macro as a CSV file so that you can open the data in Microsoft Excel, Stata, and SAS. If you do not have a floppy disk with you, save the file to the hard drive and then FTP the document to your Unix account. Files left on SSRC computers will be erased.
NOTE: If you want your data to run until the present, do not include an ending date and simply leave the two commas following the starting date.

After entering the macro, click on File and then select Save.
Return to the main Datastream screen (if it is not on the main screen, press CLEAR. The macro will not run if Datastream is not on the original screen. Select Macro from the top of the screen and the click on Run macro… Select list900a.mac from the choices on the left and then click OK. This should enable the program to start.
NOTE: For images of the above steps, see the download.mac tutorial at the top of this page.
period.mac
Use this macro to download data when you have relatively few series, but need data from a variety of periods and/or frequencies.

It is important that you save the macro as a CSV file so that you can open the data in Microsoft Excel, Stata, and SAS. If you do not have a floppy disk with you, save the file to the hard drive and then FTP the document to your Unix account. Files left on SSRC computers will be erased.
4. FOR EACH DIFFERENT DATE AND PERIOD:
NOTE: If you want your data to run until the present, do not include an ending date and simply leave the two commas following the starting date.

5. After entering the macro, click on File and then select Save.
Return to the main Datastream screen (if it is not on the main screen, press CLEAR. The macro will not run if Datastream is not on the original screen. Select Macro from the top of the screen and the click on Run macro… Select period.mac from the choices on the left and then click OK. This should enable the program to start.
NOTE: For images of the above steps, see the download.mac tutorial at the top of this page.
maxmin.mac
Use this macro to download the highest (or lowest) price of each Price High (or Price Low) of a specified period.
As with the download.mac, after finding the desired codes, click on CLEAR at the top to return to the main Datastream screen.
At the top of the screen, click on Macro and then select Edit Macro…. Select maxmin.mac from the list of choices and then click OK.

A notepad screen will appear. Change ONLY what it is within quotation marks on this screen. At the top line change the file name to a:\yourfile.csv
It is important that you save the macro as a CSV file so that you can open the data in Microsoft Excel, Stata, and SAS. If you do not have a floppy disk with you, save the file to the hard drive and then FTP the document to your Unix account. Files left on SSRC computers will be erased.
FOR EACH INDEX:
1. Within the second set of parentheses, enter the desired mnemonic.
2. Within the third set of parentheses, enter PH or PL. After the comma, enter MAX or MIN. These give the option of the MAX or MIn of the Price High or the Price Low of the day/week/month/quarter/year as selected.
3. Enter the START DATE between the first and second commas. Enter the END DATE (if used) between the second and third commas.
4. Select the desired frequency, entering D/W/M/Q/Y for daily, weekly, monthly, quarterly, or yearly.
NOTE: For instructions and images on running the macro, see the download.mac tutorial at the top of this page.