Loop and concatenate name

Moderators: statman, Analyst Techy, andris, Fierce, GerineL, Smash

jgroman77
Posts: 2
Joined: Tue Sep 24, 2013 3:40 pm

Loop and concatenate name

Postby jgroman77 » Tue Sep 24, 2013 3:43 pm

I would like to implemment the following syntax in a loop, but I don't know how to concatenate the name in the command to save the files.

GET
FILE='X:\atus\admin\ahtus\data\2003\01_orig\download\usa0312quest.sav'.

select if wave=1.

save outfile='X:\atus\admin\ahtus\data\2003\01_orig\download\usa2003quest.sav'.


GET
FILE='X:\atus\admin\ahtus\data\2003\01_orig\download\usa0312quest.sav'.

select if wave=2.

save outfile='X:\atus\admin\ahtus\data\2003\01_orig\download\usa2004quest.sav'.


GET
FILE='X:\atus\admin\ahtus\data\2003\01_orig\download\usa0312quest.sav'.

select if wave=3.

save outfile='X:\atus\admin\ahtus\data\2003\01_orig\download\usa2005quest.sav'.


GET
FILE='X:\atus\admin\ahtus\data\2003\01_orig\download\usa0312quest.sav'.

select if wave=4.

save outfile='X:\atus\admin\ahtus\data\2003\01_orig\download\usa2006quest.sav'.
Penguin_Knight
Posts: 473
Joined: Thu Apr 05, 2012 5:58 pm

Re: Loop and concatenate name

Postby Penguin_Knight » Wed Oct 02, 2013 1:22 pm

jgroman77 wrote:I would like to implemment the following syntax in a loop, but I don't know how to concatenate the name in the command to save the files.

GET
FILE='X:\atus\admin\ahtus\data\2003\01_orig\download\usa0312quest.sav'.

select if wave=1.

save outfile='X:\atus\admin\ahtus\data\2003\01_orig\download\usa2003quest.sav'.


GET
FILE='X:\atus\admin\ahtus\data\2003\01_orig\download\usa0312quest.sav'.

select if wave=2.

save outfile='X:\atus\admin\ahtus\data\2003\01_orig\download\usa2004quest.sav'.


GET
FILE='X:\atus\admin\ahtus\data\2003\01_orig\download\usa0312quest.sav'.

select if wave=3.

save outfile='X:\atus\admin\ahtus\data\2003\01_orig\download\usa2005quest.sav'.


GET
FILE='X:\atus\admin\ahtus\data\2003\01_orig\download\usa0312quest.sav'.

select if wave=4.

save outfile='X:\atus\admin\ahtus\data\2003\01_orig\download\usa2006quest.sav'.

Code: Select all

DEFINE MyMacro (WaveNum = !TOKEN(1)/
                         YearNum = !TOKEN(1)) .
GET
  FILE='X:\atus\admin\ahtus\data\2003\01_orig\download\usa0312quest.sav'.
SELECT IF wave=!WaveNum.
SAVE OUTFILE=!QUOTE(!CONCAT("X:\atus\admin\ahtus\data\2003\01_orig\download\usa", !YearNum, "quest.sav")) .
!ENDDEFINE .
EXECUTE .

MyMacro WaveNum = 1 YearNum = 2003 .
MyMacro WaveNum = 2 YearNum = 2004 .
MyMacro WaveNum = 3 YearNum = 2005 .
MyMacro WaveNum = 4 YearNum = 2006 .
EXECUTE .

Who is online

Users browsing this forum: No registered users and 1 guest

cron