Information Technology Services


HOW TO USE EXCEL FILES IN TSP

There are 2 ways to load your data into TSP. You can include the data in the TSP syntax file or it can be read in from an Excel file. Both methods are described here but the Excel method is significantly easier and faster.

To read data directly from an Excel file follow these steps:

  1. First prepare your excel file as described below - variable names should be in the first row and the data should start immediately in the next row - no empty rows are allowed. Make sure your variable names are "legal" in TSP- no more than 8 characters and no spaces or special characters.
  2. Save the Excel file as an Excel 2.x worksheet (not a workbook).
  3. Create your text file with the FREQ and SMPL commands as described below. Instead of using the LOAD command you will use the READ command. Put single quotes around your filename as shown below.
  4. FTP both your Excel data file and your TSP syntax file to shakti as described below.

To put your Excel data into a TSP file follow these simple steps:

  1. Create a text file with the necessary FREQ, SMPL, LOAD, and END commands.
  2. Open your data in Excel.
  3. If your data is in columns with each variable in a column you can just select across columns and rows the block of data you want to put in TSP. If not you will need to either type the data directly into the TSP file or reformat it in Excel.
  4. Once the data is selected copy it by choosing copy in the edit menu.
  5. Go back to your text editor and place the cursor under the LOAD command - then choose paste from the edit menu.
  6. Your data should be pasted maintaining the basic columns from Excel so you are almost done.
  7. Just make sure you have semicolons in the right paces and the syntax is correct.
  8. FTP your file to shakti as described below.

Notes on TSP syntax.
TSP files are actually simple plain text files. You can create a plain text file in a text editor such as notebook in Windows or Simple Text on a Mac. You could also use the PICO text editor on shakti (the cut and past technique described above will not work on shakti - you would have to type in your data directly). You can use a word processor such as Microsoft Word but you have to be sure to save the file as a plain text file.

Preparing your TSP syntax file.
Using a text editor or word processor enter the TSP commands required for your file. FREQ, SMPL, LOAD etc. FREQ = frequency of your data A- annual, N- none, Q- quarterly, W- weekly. SMPL = defines the sample time period: "1890 1920" covers the years between 1890 and 1920, "47:1 82:4" represents the first quarter of 1947 through the last quarter of 1982. The READ command is used to read data from an Excel file while the LOAD command us used when the data is contained in the TSP file. END = marks the end of the file.

Examples:

Reading data directly from an Excel file Data in the TSP syntax file
FREQ A;
SMPL 1820 1920;
READ(FILE= 'filename.xls');
END;

 

FREQ A;
SMPL 1890 1920;
LOAD VAR1 VAR2 VAR3;
1 1 1
2 2 2
3 3 3
4 4 4
. . .
. . .
40 40 40;
END;
This file will read in annual data for 1890 to 1920 from an Excel file named filename.xls. This file will read in annual data from 1890 to 1920 for 3 variables. Each column represents the data for each variable- separate each value with 1 or more spaces.

Preparing your Excel file.
It may take a few minutes to make sure your file is in an acceptable format but it will save headaches down the road. Make sure you follow these simple rules:

  • missing values should be represented by a single period ( . )
  • each value should be a number without any other characters such as commas (eg: 2,000) or dollar signs ($5.00)
  • each variable should be in 1 column
  • all data should be on the same worksheet
  • variable names must be no more than 8 characters long, can not start with a number and must not have spaces or special characters such as # $ % & etc.
  • the file must be saved as a worksheet not a workbook if you will be reading it in directly

How to FTP your files to shakti.
On all lab machines there is an FTP program under the information services folder. On Windows machines it is WS-FTP32.

  1. Open this program and if not already done so set it up to connect to shakti: type shakti in the "host name" box. Enter your username and password. When you connect you will see the files on the local computer on the left and the files in your directory on shakti on the right.
  2. Find your file(s) on the left side - you may need to go to the floppy if they are on disk and click the arrow between the windows which points towards the right pane with the files on shakti.
  3. The last thing you MUST do is change the names of your files into all UPPERCASE letters. You must make sure your filename has .TSP at the end. Remove .TXT if it's part of your filename.There is a button on the right-hand side labeled rename - use this to rename your files.
  4. You should now be ready to telnet to shakti and run TSP with your data.

Note for large data sets.
You may get an error message when you try to load your data that looks like this:

NOTE:    2 VARIABLES LIKE @NOB WERE DELETED TO MAKE ROOM FOR OTHERS.
NOTE:    3 PROGRAM LINES BELOW    4 WERE DELETED TO MAKE ROOM FOR OTHERS.
*** ERROR in line 3 Procedure READ: Insufficient space in blank common
    ====>    1000000
 TOTAL MEMORY REQUIRED (WORDS):     1237760
Try running a larger size of TSP, such as:
  tsp15   tsp30   tsp60  , etc. (sizes in MB of memory).
Use the  SHOW;  command in any size of TSP to show the
amount of working space, max. number of observations, etc.

The solution is to run a version of TSP that allocates more memory. Instead of typing "tsp" to run the program on shakti type "tsp15", "tsp30" etc. Start with "tsp15" then try "tsp30" and move up until you can load your data without the memory error.

 


Return to Help Guides Index

Last Modified: 01/04/2011