There is no direct way to show macro definitions. DISPLAY MACROS will show the names of defined macros but not the definitions.
However, if you run SET MPRINT ON, syntax after macro expansion will be displayed in the log. This is another reason why FILE HANDLE is a better solution.
--
Original Message:
Sent: 1/25/2024 10:23:00 AM
From: IBMcode SPSS
Subject: RE: Automating file name
Hello Patrick,
Thank you for reply.
I wanted to ask, before running the get data statement, i would like to check what are the values assigned to these macros created above?
For instance, in SAS I would have done:
%put &date; and in the SAS log would have been printed its value .
Thank you.
------------------------------
IBMcode SPSS
------------------------------
Original Message:
Sent: Thu January 25, 2024 05:14 AM
From: Patrick Henry-Lucet
Subject: Automating file name
Hello there.
I use something similar when working on different waves for a survey (with Excel files).
define !date()
[your date here]
!enddefine.
define !qdate()
!quote(!eval(!date))
!enddefine.
get data /type = xlsx
/file = 'filename' + !qbase + '.xlsx'
/sheet = name '_main_'
/cellrange = full
/readnames = on
/assumedstrwidth = 32767.
dataset name filename!date
window = front.
------------------------------
Patrick Henry-Lucet
Original Message:
Sent: Wed January 24, 2024 12:58 PM
From: IBMcode SPSS
Subject: Automating file name
Hello,
I have a SPSS program which reads a file named as "filename01012024.txt" as i am showing below:
GET DATA
/TYPE=txt
/FILE='C:\.....\filename01012024.txt'
.........................
EXECUTE.
DATASET NAME filename01012024 WINDOW=FRONT.
Because i need to run this program each time new text file is generated , i am thinking to create a macro, with date as parameter ,
and to use it in above code, so I do not need to change manually the date extension, part of the file name.
How this macro can be created and used in this scenario?
Thank you.
------------------------------
IBMcode SPSS
------------------------------