7 Replies Latest reply: May 20, 2015 11:25 AM by Jonathan Poole RSS

    loop in script to run the same code for 2 data sources

    Kristina Stephenson

      Hi All-

      I have multiple of the same structured datasets to pull in for 2 different data sources. I would like to be able to use a loop to run through the code for both data sources on the same reload instead of having to run my script twice.


      Currently, I have the following at the beginning of my script:


      SET vSource="Source1";

      SET vSource="Source2";


      When I run my script, I have to comment out one of the vSource and run the script twice, once for each vSource to run through multiple tabs that include code such as the following.



      LOAD *
      txt, codepage is 1252, embedded labels, delimiter is ',', msq);

      STORE '$(vSource)PopChar' INTO [$(vdirT1HipViews)$(vSource)\T1_$(vSource)PopChar.qvd];
      DROP TABLE $(vSource)PopChar;


      I have each table that I pull in for each data source, with the exception of two tables on the same tab that I only have for the first source. I use IF '$(vSource)'='Source1' THEN

      END IF command around code on that tab to only run for Source1.


      Should I use FOR EACH NEXT command or another type of LOOP? I have not been successful in the loop code running and not sure what I am missing.