DATA Step, Macro, Functions and more

Can you resolve my concatenation problem?

Accepted Solution Solved
Reply
Contributor
Posts: 22
Accepted Solution

Can you resolve my concatenation problem?

I am trying to prompt a user via a couple of windows for information. The first window prompts for the last two digits of an I/P address and a model type.

I am trying to build a windows file name. Our departmental standard has a convention like:      'z:\Mainframe\MF 47_'xx     where      xx      is the two digit I/P value and there are subsequent nodes of the file name to follow.

Data Work.GetIP;

      if _n_ = 1 then do;

            format Last2IP $2.;

            format VSPPLAT $4.;

            format configr1 $250.;

            format tdrv1 tdrv1a tdrv2 $120.;

       window GetBoxNo irow=1 rows=15 color=white

            #3 @10 'Enter the last two digits of the I/P address:'

                 +2 Last2IP attr=underline autoskip persist=yes

            #5 @10 'Enter Platform (ie: R700, R800):'

                 +2 VSPPLAT attr=underline persist=yes;

       display GetBoxNo blank;

     /*     so let's assume the user replies     85     to the prompt for      Last2IP     and     R800     for the prompt for      VSPPLAT                                                            */

  /* here is the first problem: trying to get the variable     configr1     to equal     z:\Mainframe\MF_47.85\Configs\Report_140531_CreateConfigurationReport\CSV               */

      tdrv1 = trim("z:\Mainframe\MF_");

      tdrv1a = cat(tdrv1,Last2IP);

      tdrv2 = trim("\Configs\Report_140531_CreateConfigurationReport\CSV");

      tdrv2a = cat(tdrv1a,tdrv2a);

      configr1 = tdrv2a;

     /*      I have tried a number of ways of concatenating a string     ("z:\Mainframe\MF_47." )     and     Last2IP     and then the string     "\Configs\Report_140531_CreateConfigurationReport\CSV")

               but run into problems with length of values or it leaves the Last2IP value out     */

     /*      Next problem: I want to retain the items entered in the previous box (but not allow update here) and display a prompt for the file name of the configuration report...displayed but the user can

               over-type if they aren't meeting the standard or the date of the report is different     */

      window GetRpt irow=1 rows=10 color=white

            #3 @10     'Enter the last two digits of the I/P address:'

               +2       Last2IP persist=yes protect=yes

            #5 @10      'Enter Platform (ie: R700, R800):'

               +2       VSPPLAT persist=yes protect=yes

            #7 @10      'Enter Filename for Configuration Report:' /

               @15      configr1 ;

       display GetRpt;

/*      I would like the cursor to tab directly to line-8, column-15 where the variable      configr1     begins but that may not be possible.     */

/*     below is relevant to subsequent steps and macro calls     */

       %LET VSPIP = Ntests;

       %LET VSPVERS = VSPPLAT;

       output;

       stop;

  end;

  output;

  STOP;

  run;

quit;

proc print data=Work.GetIP;

run;

quit;


Accepted Solutions
Solution
‎06-10-2014 04:04 PM
Super User
Posts: 11,338

Re: Can you resolve my concatenation problem?

Some basics on concatenation:

Many component strings will carry there full length, ie. leading or trailing blanks, unless removed. The older trim(left(string)) or strip(string) need to be applied at specific places. OR look at the CATT CATS CATX and possible CATQ functions.

Likely you want CATS instead of CAT.

Also look at the length of returned strings with functions.

("z:\Mainframe\MF_47." )     and     Last2IP     and then the string     "\Configs\Report_140531_CreateConfigurationReport\CSV")

configr1= cats("z:\Mainframe\MF_47.",Last2IP, "\Configs\Report_140531_CreateConfigurationReport\CSV");

you may even find

configr1 = cats(tdrv1,Last2ip,tdrv2);

will work without all of the reassignements and trim calls.

View solution in original post


All Replies
Solution
‎06-10-2014 04:04 PM
Super User
Posts: 11,338

Re: Can you resolve my concatenation problem?

Some basics on concatenation:

Many component strings will carry there full length, ie. leading or trailing blanks, unless removed. The older trim(left(string)) or strip(string) need to be applied at specific places. OR look at the CATT CATS CATX and possible CATQ functions.

Likely you want CATS instead of CAT.

Also look at the length of returned strings with functions.

("z:\Mainframe\MF_47." )     and     Last2IP     and then the string     "\Configs\Report_140531_CreateConfigurationReport\CSV")

configr1= cats("z:\Mainframe\MF_47.",Last2IP, "\Configs\Report_140531_CreateConfigurationReport\CSV");

you may even find

configr1 = cats(tdrv1,Last2ip,tdrv2);

will work without all of the reassignements and trim calls.

Contributor
Posts: 22

Re: Can you resolve my concatenation problem?

Thanks, I'd tried a couple of variations of the CAT,CATS,CATX functions but this last statement worked perfectly.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 209 views
  • 0 likes
  • 2 in conversation