<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: edit a string based on obs number in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/edit-a-string-based-on-obs-number/m-p/711911#M219372</link>
    <description>&lt;PRE&gt;data I have:
School	TeamLead	enrichID   ps_Last	ps_first
Keowee 	Bravo, Echo	21004	    West	Ken&lt;/PRE&gt;
&lt;PRE&gt;data I want:

School	TeamLead	enrichID	ps_Last	ps_first	hlink
North         smith, joe        12345       delta         alpha      =HYPERLINK("https://docs.google.com/forms/d/e/viewform?usp=pp_url&amp;amp;entry.1462554928="&amp;amp;B2&amp;amp;"&amp;amp;entry.756145072="&amp;amp;A2&amp;amp;"&amp;amp;entry.1518077367="&amp;amp;C2&amp;amp;"&amp;amp;entry.1394336521="&amp;amp;E2&amp;amp;"&amp;amp;entry.127408784="&amp;amp;D2&amp;amp;&lt;BR /&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;This is observation 1. the hyperlink for observation 2 follows below. The salient point is that B2 is now B3, A2 is now&amp;nbsp; A3, etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;=HYPERLINK("https://docs.google.com/forms/d/e/viewform?usp=pp_url&amp;amp;entry.1462554928="&amp;amp;B3&amp;amp;"&amp;amp;entry.756145072="&amp;amp;A3&amp;amp;"&amp;amp;entry.1518077367="&amp;amp;C3&amp;amp;"&amp;amp;entry.1394336521="&amp;amp;E3&amp;amp;"&amp;amp;entry.127408784="&amp;amp;D3&amp;amp;"
&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 17 Jan 2021 02:38:36 GMT</pubDate>
    <dc:creator>GreggB</dc:creator>
    <dc:date>2021-01-17T02:38:36Z</dc:date>
    <item>
      <title>edit a string based on obs number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/edit-a-string-based-on-obs-number/m-p/711865#M219347</link>
      <description>&lt;P&gt;I am creating 149 excel files that will be dragged into Google drive and used to prefill a Google form.&amp;nbsp; The hyperlink for the first obs is shown here.&lt;/P&gt;
&lt;P&gt;=HYPERLINK("text...text..&amp;amp;entry.14="&amp;amp;B2&amp;amp;"&amp;amp;entry.75="&amp;amp;A2&amp;amp;"&amp;amp;entry.15="&amp;amp;C2&amp;amp;"&amp;amp;entry.13="&amp;amp;E2&amp;amp;"&amp;amp;entry.12="&amp;amp;D2&amp;amp;"")&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My task is to edit the substrings "&amp;amp;B2&amp;amp;"&amp;nbsp;&amp;nbsp;"&amp;amp;A2&amp;amp;"&amp;nbsp;&amp;nbsp;"&amp;amp;C2&amp;amp;"&amp;nbsp; &amp;nbsp;"&amp;amp;E2&amp;amp;"&amp;nbsp; and&amp;nbsp;"&amp;amp;D2&amp;amp;".&amp;nbsp; The logic is straightforward. The number in the substrings increments by one. At observation 2, the substrings will be&amp;nbsp;"&amp;amp;B3&amp;amp;"&amp;nbsp;&amp;nbsp;"&amp;amp;A3&amp;amp;"&amp;nbsp;&amp;nbsp;"&amp;amp;C3&amp;amp;"&amp;nbsp; &amp;nbsp;"&amp;amp;E3&amp;amp;"&amp;nbsp; and&amp;nbsp;"&amp;amp;D3&amp;amp;".&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At observation 3, the substrings will be&amp;nbsp;"&amp;amp;B4&amp;amp;"&amp;nbsp;&amp;nbsp;"&amp;amp;A4&amp;amp;"&amp;nbsp;&amp;nbsp;"&amp;amp;C4&amp;amp;"&amp;nbsp; &amp;nbsp;"&amp;amp;E4&amp;amp;"&amp;nbsp; and&amp;nbsp;"&amp;amp;D4&amp;amp;" .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA I HAVE:&lt;/P&gt;
&lt;P&gt;LAST&amp;nbsp; &amp;nbsp; &amp;nbsp;FIRST&amp;nbsp; &amp;nbsp; &amp;nbsp;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;SCHOOL&amp;nbsp; &amp;nbsp; TEACHER&amp;nbsp; &amp;nbsp; &amp;nbsp; HLINK&lt;/P&gt;
&lt;P&gt;smith&amp;nbsp; &amp;nbsp; &amp;nbsp; joe&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;001&amp;nbsp; &amp;nbsp; &amp;nbsp; north high&amp;nbsp; &amp;nbsp; quarles&amp;nbsp; &amp;nbsp; &amp;nbsp; =HYPERLINK("etc"&amp;amp;B2&amp;amp;"etc="&amp;amp;A2&amp;amp;"&amp;amp;etc="&amp;amp;C2&amp;amp;"etc"&amp;amp;E2&amp;amp;" etc"&amp;amp;D2&amp;amp;"")&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Jan 2021 18:28:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/edit-a-string-based-on-obs-number/m-p/711865#M219347</guid>
      <dc:creator>GreggB</dc:creator>
      <dc:date>2021-01-16T18:28:08Z</dc:date>
    </item>
    <item>
      <title>Re: edit a string based on obs number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/edit-a-string-based-on-obs-number/m-p/711874#M219352</link>
      <description>&lt;P&gt;so, you don't want to change/edit any of your data except you want to create an Excel Workbook with an Excel Function called Hyperlink, which will use the current obs + 1 (among other) as input, correct?&lt;/P&gt;</description>
      <pubDate>Sat, 16 Jan 2021 19:16:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/edit-a-string-based-on-obs-number/m-p/711874#M219352</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-01-16T19:16:16Z</dc:date>
    </item>
    <item>
      <title>Re: edit a string based on obs number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/edit-a-string-based-on-obs-number/m-p/711875#M219353</link>
      <description>Correct.&lt;BR /&gt;</description>
      <pubDate>Sat, 16 Jan 2021 19:20:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/edit-a-string-based-on-obs-number/m-p/711875#M219353</guid>
      <dc:creator>GreggB</dc:creator>
      <dc:date>2021-01-16T19:20:13Z</dc:date>
    </item>
    <item>
      <title>Re: edit a string based on obs number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/edit-a-string-based-on-obs-number/m-p/711876#M219354</link>
      <description>&lt;P&gt;And where do the 149 files come from?&lt;/P&gt;</description>
      <pubDate>Sat, 16 Jan 2021 19:21:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/edit-a-string-based-on-obs-number/m-p/711876#M219354</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-01-16T19:21:12Z</dc:date>
    </item>
    <item>
      <title>Re: edit a string based on obs number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/edit-a-string-based-on-obs-number/m-p/711878#M219355</link>
      <description>&lt;P&gt;I'm not entirely sure what you want to link to here? Are the links build from values that are already in your SAS data set?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyways, see if you can use this as a template.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data out;
   set sashelp.class;
   link = cats('=HYPERLINK("A', _N_ + 1, '")');
run;

ods excel file = "YOURPATHHERE\file.xlsx";

proc print data = out;
run;

ods excel close;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 16 Jan 2021 19:32:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/edit-a-string-based-on-obs-number/m-p/711878#M219355</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-01-16T19:32:14Z</dc:date>
    </item>
    <item>
      <title>Re: edit a string based on obs number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/edit-a-string-based-on-obs-number/m-p/711880#M219357</link>
      <description>&lt;P&gt;It is not clear what you want to do here. Please show the hyperlink you want to generate as plain text, use the insert code button (looks like &amp;lt; / &amp;gt;) to get a pop-up window so you can paste the links as text and the forum won't try to re-format them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the links actually need to use &amp;amp; character in them then make sure to use single quotes instead of double quotes in the code that tries to use them as string literals. Otherwise the SAS macro processor is going to interpret &amp;amp;A2 as a reference to a macro variable named A2.&lt;/P&gt;</description>
      <pubDate>Sat, 16 Jan 2021 19:39:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/edit-a-string-based-on-obs-number/m-p/711880#M219357</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-01-16T19:39:31Z</dc:date>
    </item>
    <item>
      <title>Re: edit a string based on obs number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/edit-a-string-based-on-obs-number/m-p/711911#M219372</link>
      <description>&lt;PRE&gt;data I have:
School	TeamLead	enrichID   ps_Last	ps_first
Keowee 	Bravo, Echo	21004	    West	Ken&lt;/PRE&gt;
&lt;PRE&gt;data I want:

School	TeamLead	enrichID	ps_Last	ps_first	hlink
North         smith, joe        12345       delta         alpha      =HYPERLINK("https://docs.google.com/forms/d/e/viewform?usp=pp_url&amp;amp;entry.1462554928="&amp;amp;B2&amp;amp;"&amp;amp;entry.756145072="&amp;amp;A2&amp;amp;"&amp;amp;entry.1518077367="&amp;amp;C2&amp;amp;"&amp;amp;entry.1394336521="&amp;amp;E2&amp;amp;"&amp;amp;entry.127408784="&amp;amp;D2&amp;amp;&lt;BR /&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;This is observation 1. the hyperlink for observation 2 follows below. The salient point is that B2 is now B3, A2 is now&amp;nbsp; A3, etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;=HYPERLINK("https://docs.google.com/forms/d/e/viewform?usp=pp_url&amp;amp;entry.1462554928="&amp;amp;B3&amp;amp;"&amp;amp;entry.756145072="&amp;amp;A3&amp;amp;"&amp;amp;entry.1518077367="&amp;amp;C3&amp;amp;"&amp;amp;entry.1394336521="&amp;amp;E3&amp;amp;"&amp;amp;entry.127408784="&amp;amp;D3&amp;amp;"
&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 17 Jan 2021 02:38:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/edit-a-string-based-on-obs-number/m-p/711911#M219372</guid>
      <dc:creator>GreggB</dc:creator>
      <dc:date>2021-01-17T02:38:36Z</dc:date>
    </item>
    <item>
      <title>Re: edit a string based on obs number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/edit-a-string-based-on-obs-number/m-p/711942#M219395</link>
      <description>&lt;P&gt;As suggested by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp;, you can use the CATS function to generate the string. I think the function call you want is something like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  hlink=cats(
         '=HYPERLINK("https://docs.google.com/forms/d/e/viewform?usp=pp_url&amp;amp;entry.1462554928="&amp;amp;B',
         _N_+1,
         '&amp;amp;"&amp;amp;entry.756145072="&amp;amp;A',
         _N_+1,
         '&amp;amp;"&amp;amp;entry.1518077367="&amp;amp;C',
         _N_+1,
         '&amp;amp;"&amp;amp;entry.1394336521="&amp;amp;E',
         _N_+1,
         '&amp;amp;"&amp;amp;entry.127408784="&amp;amp;D',
         _N_+1,
         '&amp;amp;"")');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;where _N_ is the "iteration number" (automatic variable) of the data step, when you just read a single table, it is also the observation number.&lt;/P&gt;</description>
      <pubDate>Sun, 17 Jan 2021 12:25:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/edit-a-string-based-on-obs-number/m-p/711942#M219395</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2021-01-17T12:25:57Z</dc:date>
    </item>
  </channel>
</rss>

