Hi,
No, I was not sure at all :)
However, I managed to solve the problem the following way:
define !rename4 (vlist = !charend('/'))
!let !count = 1
!let !incr = 1
!let !incrtwo=2
!let !subtr=-1
!do !vname !in (!vlist)
!let !len=!length(!vname)
!let !lastbutonecharacter = !length(!concat(!blank(!len), !blank(!subtr)))
!let !lastcharacter=!length(!concat(!blank(!lastbutonecharacter), !blank(!incrtwo)))
!let !lastletter= !substr(!vname, !len, !incr)
!if (!lastletter = A) !then
!let !count=1
!ifend
!let !newname0 = !substr(!vname, 1, !lastbutonecharacter)
!let !newname1 = !concat(!newname0,"_")
!let !newname = !concat(!newname1, !count)
rename variables (!vname = !newname).
!let !count = !length(!concat(!blank(!count), !blank(!incr)))
!doend
!enddefine.
It may not be the cleanest solution, but it works and for the time being this is the most important for me.
By the way: is there a source where I can check the functions that can be used in SPSS macros?
Thanks for the answer in advance,
Oti
------------------------------
Otília Csörgő
------------------------------
Original Message:
Sent: Sun October 20, 2024 12:02 PM
From: Kirill Orlov
Subject: SPSS macro problem with substr and condition
Are you sure !last() function exists in SPSS macro language?
------------------------------
Kirill Orlov
------------------------------