SPSS syntax for beginner

#1
Hi Talk Stats!
I'm a medical student currently working on a scientific paper. I want to try using SPSS to do my statistical analysis for the paper. I have no experience in SPSS or any other statistical software so it is quite the learning curve for me. I'm hoping to find some help here.

The paper i'm trying to write is based of medical records from 3 existing databases.
The first database is a collection of medical examinations (lung function tests, radiological protocols,...) and personal information (date of birth, nationality, home adress, years of smoking, ...)
The second database is a collection of jobs the patients have worked at with type of job, starting date and end date.
The third database is a collection of a measurement of disability at different points in time. So at time x the patient had y% disability.
All examinations, jobs and disabliltypercentages are connected to a unique case number for that patient. These are the same number in all the databases.

Now the thing i'm trying to do is collect this information in 1 database where I can do my analyses. The variables in this database would be:
Case number, adress, number of years worked in each jobtype, how many years of smoking, the results of the worst lung function tests and worst radiological protocol and highest disability percentage.

Now after some googling I think the easiest way of doing all this is via a SPSS syntax script. The things I will need to do in this script would be:
1- make a new database
2- Calculate how many years worked in every jobtype
+ Load the correct variables from database 2
+ calculate the difference of end date and start date
+ take the sum of each jobtype for each case number
+ write this to the new database
3- Add highest vallue from examinations and disability percentage
+ Load database
+ check for each casen umber the worst value for each variable
+ write to the new database

So the parts of code I would need are:
1 make a new database
2 load variables from different databases than the one loaded now
3 calculations with dates to get total years worked for 1 job
4 sum of these calculations for one case number
5 writing the new value in a new varriable for this case number
6 checking the highest value for one varriable for one case number
7 creating 'scratch varriables'

My question to you is: is this possible with the syntax of SPSS? Is there an easier solution? And do you have any tips before I start searching which code to use? Do you know any of the parts of code in the syntax I could use for this problem?

All help is welcome!
 
#2
Make sure that you have a "key" variable in each of the files that you want to merge (like patient number or something)

Click on "Data"/ Merge Files/Add variables...

select a file to be merged/ choose and Key variable

In the end click on "Paste" (not on "OK") That will open a syntax file where your commands will be. Write some comments and save the syntax file.

For all of your commands you click on "Paste" instead of "OK".

- - -

Next time, if you want to ask something (about software use), make a small reproducible example with 3 variables and 5 observations.