Installing Spectre (Clinical) on Windows


Note: If you arrived at this page directly using a search engine such as Google then this may not be the "Spectre" you are looking for. There are a few software packages of this name. This "Spectre" is to do with clinical trials reporting.

Introduction

If you just want to use the %npcttab and %unistats macros but do not want to set up the whole of Spectre (Clinical) then installing it is easy. All you need to do is download the macros and copy them to a directory that you then define to sasautos and then everything should work fine. The rest of the information you can read here is to do with a full Spectre (Clinical) install for those users planning to set up a full clinical reporting system. If this does not apply to you then skip the rest of this page.

There are a number of steps to installing Spectre. Some changes to a shell script are needed. Other changes require a lot of thought, such as how to allocate libraries for your sas programs as Spectre might need this to be done differently to your established method. I will be updating this page as I get feedback from users who have attempted to do this installation. There will be things I have missed out and places where I have given unclear instructions so please send me feedback by email on what is missing or what is wrong so that I can improve this page. There is a contact link for me at the bottom of this page.

If you are doing this installation yourself and you have never done an installation like this before then use the following guidelines:

What you do not get with the Windows version

The Windows version of Spectre lacks the support for conversion to PostScript and thence to bookmarked PDFs. Since Spectre uses PostScript for printing, the printing scripts in Spectre will not work in this case. If you want to print Spectre output on Windows then you should use your existing methods for this.

Cygwin

In order for Spectre to work on Windows, you need to install the Cygwin Linux emulator. This is so that the Spectre scripts can run. To find out how to install Cygwin on your PC, consult the Cygwin web site. Do a typical installation and add the extra things you need later. At the start of installing Cygwin you will be shown a screen that shows the directory it will download to and below it on the left will be "Install For" for which you should choose the recommended "All Users" (unless you really don't want other people to have access to it) and on the right "Default Text File Type" for which you should change the default so that it becomes the non-recommended "DOS /text".

gawk and ssmtp

Some of the scripts require ssmtp (an email package) and gawk so you need to make sure you have installed them from Cygwin. You can do this as a later install. The gawk version installed should be 3.1.4 or higher.

Make sure your .bashrc is working

A number of edits has to be made to your .bashrc file in your home directory but you have got to be sure this .bashrc member is being called and run (sourced). If you have just completed a Cygwin installtion then check that this file is in your home directory. You can either use the Windows Explorer or list the files that start with a period in your Cygwin home directory using the command:
 
echo .*

When I installed Cygwin on my PC it automatically put my .bashrc member in my home directory. This is the correct situation. However, I am hearing of plenty of cases where a Cygwin installation was done but this .bashrc member was found to be missing. This is an error and how to correct this will be explained here.

If your .bashrc member is missing or empty then you should copy it from /etc/defaults/etc/skel/.bashrc

To test that your .bashrc in your home directory is being called then add the following command near the top of the file:
 
echo Hello from my .bashrc

....then when you start up your Cygwin session next time this "Hello from my .bashrc" message should be displayed. If it is, then that is good. You can delete this test message from your .bashrc member when you make the edits to it as detailed in the next section "Changes to .bashrc".

If you do not see this message when you start Cygwin, even though you put the above command in your .bashrc member, then something is wrong. You will be given instructions here to resolve this situation to make sure your .bashrc member in your home directory is actually being run (sourced) when you start Cygwin.

First check your home directory and what shell is defined to you in the /etc/passwd file. Browse this file and take a look. I have an "Roland" entry shown below. The last two field members (separated by colons) are "/home/Roland" that says where my home directory is and "/bin/bash" that says my start-up shell is "bash". If your home directory entry is not in the form /home/something then edit this file to correct it (after making a backup). Also, your start-up shell must be "/bin/bash" otherwise it will not call your .bashrc member so change it to this if it is not.
 
Roland:unused_by_nt/2000/xp:1006:513:U-DELL1\Roland,S-1-5-21-2888820645-753754486-1581935503-1006:/home/Roland:/bin/bash

Your .bashrc member is "sourced" from your .bash_profile member in your home directory. If your .bash_profile member is missing or empty then you should copy it from /etc/defaults/etc/skel/.bash_profile

It could be that the problem is in your .bash_profile member. Near the top of that member you should see it "sourcing" the .bashrc file as follows:
 
# source the users bashrc if it exists
if [ -e "${HOME}/.bashrc" ] ; then
  source "${HOME}/.bashrc"
fi

Maybe you see something like that in your .bash_profile member but for some reason it is commented out. Try uncommenting it by removing the leading "#" from the script code so it looks the same as above. Also, make sure your system environment variable HOME is resolving OK by using this command.
 
$ echo $HOME
/home/Roland

Do you get a "/home/something" result like I do? If you get nothing then your HOME environment variable is not set and bash will look for the .bashrc file in the top directory /.bashrc

You must get your .bashrc member active and working before you can continue with the Spectre installation. I believe the actions above will resolve all situations where your .bashrc is not being sourced. I am no Cygwin expert, though, so if you have tried the above and you still can not get out your "Hello from my .bashrc" test message from the command you put in your .bashrc member then you will have to ask for help on the Cygwin mailing list aimed at getting your .bashrc member sourced, after you have tried searching through the archives at www.cygwin.com to try to resolve your problem. Nothing less than this will get your problem resolved. Do not continue with the installation of Spectre until this has been resolved. When you do resolve it fully, in the sense that you get your .bashrc working, rather than using a workaround, then please let me know by email what your problem was and how it was resolved so I can expand this section to help other installers.

Changes to .bashrc

Once you have installed Cygwin and you are sure your .bashrc member is working then you need to make some edits to it. To call SAS from the Linux emulator session you will have to add the directory that contains the sas executable (sas.exe) to your PATH declaration. If you don't know where it is located then do a file search on Windows on the SAS directories contained in the "Program Files" subfolder. You should also add the Spectre scripts to the PATH statement. Also, because SAS on Windows will not recognise Unix-style path names, you will have to declare your home directory in a way that SAS will understand it. For the Spectre scripts that call SAS, a variable HOMEW is set up and exported for this. The relevant entries in my .bashrc file are shown below.
 
# Add Spectre scripts to the path as well as the sas executables 
# For SAS Learning Edition 1.0 on Windows 98 
#PATH=$PATH:/cygdrive/c/spectre/scripts:/cygdrive/c/PROGRA~1/SASINS~1/SAS/v8 

# For SAS Learning Edition 4.1 on Windows XP - note that file names containing spaces must be quoted 
PATH=$PATH:/cygdrive/c/spectre/scripts:/cygdrive/c/"Program Files"/SAS/"SAS Learning Edition 4.1" 

# Set up HOMEW as a Windows path so SAS on Windows knows where my home directory is 
HOMEW=C:\\cygwin\\home\\$USER 

export HOMEW

I do not like any of the editors that come with Cygwin so for editing a file I use Wordpad and for browsing a file I use "less". I have no problem accessing "less" but in order to be able to use Wordpad I have to define its location to my PATH as shown below. You might choose to do the same. Note that if you use Wordpad as an editor or browser then it will not understand unix-style path names. It will only work properly for files without a path that are in the current directory.
 
# Make Wordpad available as an editor
PATH=$PATH:/cygdrive/c/"Program Files"/"Windows NT"/Accessories

Changes to cygwin.bat

In the top Cygwin directory you will find the DOS command file cygwin.bat and I have edited this to add some things I need. I use "rxvt" as a terminal window (this can be downloaded from the Cygwin site) and I have set up two environment variables named EDITOR and VISUAL. The Spectre scripts will check if these have been set and for editing tasks called within a script it will use what is defined to EDITOR and for browsing a file it will use what is defined to VISUAL if set, otherwise will default to browsing using "less". Here is the change I made to my cygwin.bat

Before any changes....
@echo off

C:
chdir C:\cygwin\bin

bash --login -i

Here is my edited version. Note that you must have the CYGWIN variable set up for Spectre scripts to work correctly. This may be set even though there is no entry in cygwin.bat. To find out, use the command "set | grep CYGWIN" to see if you get a line that starts with "CYGWIN=". Also, if you are going to use Wordpad as an editor, then you must define its location to the PATH statement as I showed you above in the changes to .bashrc . You can also assign Wordpad to VISUAL but I do not like to this this as it allows the user to edit the file they open which I do not want. There is no option you can use with Wordpad to open it in read-only mode, which is a shame. Note that if you use Wordpad as an editor or browser then it will not understand unix-style path names. It will only work properly for files without a path that are in the current directory.

After the changes I made....
@echo off
C:
chdir C:\cygwin\bin
set EDITOR=wordpad
set VISUAL=less
set CYGWIN=codepage:oem tty binmode title
rxvt -e bash --login -i

Allocating macros and libraries

If you are the installer and not a programmer then you should inform the senior programmer of the existence of the following page and tell them that they have to take action on it.

Allocation of Libraries for Spectre

Macros and scripts

Spectre consists of three components; html documentation, macros and shell script. Only the macros and shell scripts need to be downloaded and installed. The macros and shell scripts must each have their own library. The shell script library will have to be added to the PATH system environment variable for users of Spectre at a point that is fairly early on the path so that Spectre shell scripts take precedence over possible duplicate shell script names on the system. What you need are the names of these two directories.

Once you know the names of the two libraries then you are ready to download. Both the macros and scripts come as zip files and the links to download them are highlighted in this sentence. Some of the files are not wanted and you will be told which ones to delete after you have unzipped them into their folders.

For the macros you should delete any html and text files so delete "*.html" and "*.txt".

For the scripts you do not need any of the html or text files so delete "*.html", "*.txt"..

Note that the scripts have to be executable. The following command should make them so if issued from the same directory.
 
chmod +x *

Editing the "getfields" script

I have a number of scripts that generate sas program headers. They pick out the names of the client, office, drug, protocol and increment from the path name -- but based on my own directory structure. Your directory structure might be very different. In any case, you might not like my program headers and so will handle this yourself. But whatever, you will need to edit the script getfields to display the client, office, drug, protocol and increment. Anybody who writes scripts will find this easy to amend. If you have a support contract with me then I might do it for you.

Creating @index.txt in the scripts and macros directory

When you installed the macros and scripts you were asked to delete files named @index.txt and this was intentional. Now is the time to recreate these files to test the installation so far. Assuming the script directory is on your path and the scripts that call SAS software have been correctly changed then it should be possible to run the script newix in each of the scripts and macros directly and it should create the file @index.txt . First "cat @index.txt". If the file is there then delete it. Next use the command "newix" to recreate the "@index.txt" file.
 
newix

What happened? Is the "@index.txt" file correctly created when you run the "newix" command? This is the first hurdle to overcome in the installation process. The supplied @index.txt for macros looks like this and for scripts it looks like this. Is that what you got? Did you get any file created? You might have got a script error, in which case you can probably fix it. If you got an error within the SAS software code that caused it to stop then there is no log file. The reason there is no log file is because it gets deleted at the end of the script. To stop it being deleted then put a "#" in front of the log file name. That turns the rest of the line into a commant. Once it is working then remove the "#" you added. When you have got over this hurdle then relax. The first hurdle has been overcome.

Getting "showfmts" and "showfmt" working

The next hurdle to jump is getting the scripts "showfmts" and "showfmt" working. These are the scripts that display a list of all formats and details of a specific format. Taking "showfmts" to start with, this will only work if the allocation macro reference has been changed and the new allocation macro is working (if any), that the Spectre macros are on the sasautos= path and that the correct formats are assigned to the fmtsearch= path within the new allocation macro (or correctly done in the autoexec member if an allocation macro is no longer required). Assuming you are in a study data directory then type in the command:
 
showfmts

What happened? If you got nothing then keep the sas log by putting a "#" in front of its name in the delete statement at the end of the script. You may have to add the "mprint" option to the SAS software code in that script to help work out what is wrong.

When you get it working then try out the "showfmt" script as well on one of the formats listed out by the "showfmts" script. Character formats will need to have the dollar sign preceded by a "\" escape character to stop Unix assuming it is a Unix variable. Try showfmt on a numeric variable if need be. Does it work?

This is the second hurdle. Once this has been overcome then the rest should be easy.

Make the two directories read only

Assuming everything is working so far then it is time to make the members of the scripts directory and macros directory read only. The following command should work:
 
chmod g-w *

It would be a good idea if the directory itself had no update access for the users otherwise one of them might manage to delete one or two of the members.

Conclusion

If you have got this far then you should be ready to use Spectre. I am sure I have forgotten something that should be on this page and I am sure you will hit extra problems, though. You can always email me (contact link below) and I will try to help, even if you do not have a support contract. If the latter then I may not be able to give much of my time, it depends on my priorities, but I will do what I can and am interested in having feedback from people who have gone through this installation process.


 

Use the "Back" button of your browser to return to the previous page.

contact the author

































SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration.

More on bashrc and along with spectre
The Fastest FTP Client on the Planet, FREE GoFTP Client