<?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: Having Trouble with Macro Variables in SAS When Including If Then Statements in Data Step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902356#M356597</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19879"&gt;@Quentin&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Agree with Paige.&amp;nbsp; If you can show the code that works (without macro variables), hopefully along with a small amount of sample data (like data step with CARDS statement to generate 5 rows of data), then we can help you with figuring out how to write a macro to generate that code.&amp;nbsp; Without that, we're guessing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That said, I made a little example that does *something* similar to what you are asking. I don't think this is the answer, but it is the kind of thing you are doing.&amp;nbsp; Note one reason that this is not the answer is that if you call this macro multiple times, it will overwrite the work.two each time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data one ;
  input id $7. pidn redcap_version $3. ;
  cards ;
CAAA001 3357 foo 
CAAA002 3358 bar 
;


%macro comb(idn, pidn);
data two; 
  set one; 
  if id=&amp;amp;idn
  then qi106=cats(redcap_version, "DataEntry/index.php?pid=", pidn, '&amp;amp;id=', &amp;amp;idn); 
  else qi106=""; 

  put qi106= ;
run; 
%mend ;

%comb("CAAA001", 3357)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This returns:&lt;/P&gt;&lt;PRE&gt;qi106=fooDataEntry/index.php?pid=3357&amp;amp;id=CAAA001
qi106=&lt;/PRE&gt;&lt;P&gt;But really, if you can give a small amount of sample input data, and describe the output data you want (a new variable with a string with the value .... ), people will be able to help you more.&amp;nbsp; It's rare that you need to write a macro that runs hundreds of times.&amp;nbsp; It could be a case where you could use something more basic, like a merge or SQL join.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19879"&gt;@Quentin&lt;/a&gt;&amp;nbsp;, this is close to what I'm looking for. However, is there a reason why qi106 is blank for the second record? Is there a way to get it to appear? What if you have more records?&lt;/P&gt;</description>
    <pubDate>Thu, 09 Nov 2023 16:38:02 GMT</pubDate>
    <dc:creator>JackZ295</dc:creator>
    <dc:date>2023-11-09T16:38:02Z</dc:date>
    <item>
      <title>Having Trouble with Macro Variables in SAS When Including If Then Statements in Data Step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902292#M356562</link>
      <description>&lt;P&gt;Hi! I'm trying to create a macro that concatenates values for a variable if certain conditions are met.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code is as follows, but the macro variables don't seem to initiate. Does anyone know what I am doing wrong? Any input regarding this would be much appreciated! Thanks so much!&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%macro comb(idn, pidn, eventn, eventnum, pagen, instancen) 
data two; 
set one; 
if id=idn and pid=pidn and unique_event_name=eventn and event_id=eventnum and page=pagen and instance=instancen
then qi106=cats(redcap_version, "DataEntry/index.php?pid=", pidn, "&amp;amp;id=", idn, "&amp;amp;page=", pagen, "&amp;amp;event_id=", eventnum, "&amp;amp;instance=", instancen); 
else qi106=""; 
run; 
%comb("CAAA001", 3357, "consent_arm_1",48831, "cf_consent_form_documentation", 1)
%comb("CAAA001", 3357, "eligibility_arm_1",48806, "sc_screening_form", 1)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Nov 2023 13:15:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902292#M356562</guid>
      <dc:creator>JackZ295</dc:creator>
      <dc:date>2023-11-09T13:15:23Z</dc:date>
    </item>
    <item>
      <title>Re: Having Trouble with Macro Variables in SAS When Including If Then Statements in Data Step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902293#M356563</link>
      <description>You need to resolve your macro vars&lt;BR /&gt;&lt;BR /&gt;id=&amp;amp;idn and pid=&amp;amp;pidn...</description>
      <pubDate>Thu, 09 Nov 2023 13:18:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902293#M356563</guid>
      <dc:creator>rudfaden</dc:creator>
      <dc:date>2023-11-09T13:18:29Z</dc:date>
    </item>
    <item>
      <title>Re: Having Trouble with Macro Variables in SAS When Including If Then Statements in Data Step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902294#M356564</link>
      <description>&lt;P&gt;In addition to what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/117666"&gt;@rudfaden&lt;/a&gt;&amp;nbsp;said, you have omitted a semi-colon, and you need to end the macro definition with&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 13:22:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902294#M356564</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-11-09T13:22:11Z</dc:date>
    </item>
    <item>
      <title>Re: Having Trouble with Macro Variables in SAS When Including If Then Statements in Data Step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902299#M356565</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;, thanks for your help. Despite doing all of that, I am still getting the following errors:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WARNING: Apparent symbolic reference ID not resolved.&lt;BR /&gt;WARNING: Apparent symbolic reference PAGE not resolved.&lt;BR /&gt;WARNING: Apparent symbolic reference EVENT_ID not resolved.&lt;BR /&gt;WARNING: Apparent symbolic reference INSTANCE not resolved.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a reason why that is happening?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 13:36:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902299#M356565</guid>
      <dc:creator>JackZ295</dc:creator>
      <dc:date>2023-11-09T13:36:35Z</dc:date>
    </item>
    <item>
      <title>Re: Having Trouble with Macro Variables in SAS When Including If Then Statements in Data Step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902306#M356566</link>
      <description>&lt;P&gt;Show us the full code you are using.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, run the command&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mprint;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;then run your code again and show us the entire log.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 13:46:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902306#M356566</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-11-09T13:46:11Z</dc:date>
    </item>
    <item>
      <title>Re: Having Trouble with Macro Variables in SAS When Including If Then Statements in Data Step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902312#M356568</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;, many thanks for your help. Here is the code I'm running:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;/*Importing Final Data Set*/ 
options MSGLEVEL=I;
options validvarname=v7;
proc import out=one
datafile='C:\Users\JAZHU\Desktop\LHC_Links\Excel_for_SAS.xlsx'
DBMS=xlsx replace;
getnames=yes;
run;

proc print data=one (obs=10); 
run; 

proc contents data=one; 
run;
%macro comb(idn, pidn, eventn, eventnum, pagen, instancen);
data two; 
set one; 
if id=&amp;amp;idn and pid=&amp;amp;pidn and unique_event_name=&amp;amp;eventn and event_id=&amp;amp;eventnum and page=&amp;amp;pagen and instance=&amp;amp;instancen
then qi106=cats(redcap_version, "DataEntry/index.php?pid=", &amp;amp;pidn, "&amp;amp;id=", &amp;amp;idn, "&amp;amp;page=", &amp;amp;pagen, "&amp;amp;event_id=", &amp;amp;eventnum, "&amp;amp;instance=", &amp;amp;instancen) 
else qi106=""; 
run; 
%mend;
%comb(id, pid, unique_event_name,event_id, page, instance);

options mprint;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Basically, I am trying to create a new variable, qi106, that is a concatenation of the values of a variety of variables. This is to be done for each row in my dataset, and my dataset has 172225 rows. The variables of my dataset are as follows:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JackZ295_0-1699538521925.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/89587i3FA92DFB27B5AD9B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JackZ295_0-1699538521925.png" alt="JackZ295_0-1699538521925.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The log is here:&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: Copyright (c) 2016 by SAS Institute Inc., Cary, NC, USA.&lt;BR /&gt;NOTE: SAS (r) Proprietary Software 9.4 (TS1M7)&lt;BR /&gt;Licensed to J HPKNS UNV-BLOOMBERG SCH OF PUB HLTH DEPT OF EPID, Site 70092145.&lt;BR /&gt;NOTE: This session is executing on the X64_10PRO platform.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: Analytical products:&lt;/P&gt;&lt;P&gt;SAS/STAT 15.2&lt;BR /&gt;SAS/ETS 15.2&lt;BR /&gt;SAS/OR 15.2&lt;BR /&gt;SAS/IML 15.2&lt;BR /&gt;SAS/QC 15.2&lt;/P&gt;&lt;P&gt;NOTE: Additional host information:&lt;/P&gt;&lt;P&gt;X64_10PRO WIN 10.0.19041 Workstation&lt;/P&gt;&lt;P&gt;NOTE: SAS initialization used:&lt;BR /&gt;real time 0.94 seconds&lt;BR /&gt;cpu time 0.78 seconds&lt;/P&gt;&lt;P&gt;1 /*Importing Final Data Set*/ options MSGLEVEL=I;&lt;BR /&gt;2 options validvarname=v7;&lt;BR /&gt;3 options mprint;&lt;BR /&gt;4 proc import out=one&lt;BR /&gt;5 datafile='C:\Users\JAZHU\Desktop\LHC_Links\Excel_for_SAS.xlsx'&lt;BR /&gt;6 DBMS=xlsx replace;&lt;BR /&gt;7 getnames=yes;&lt;BR /&gt;8 run;&lt;/P&gt;&lt;P&gt;NOTE: VARCHAR data type is not supported by the V9 engine. Variable id has been converted to CHAR&lt;BR /&gt;data type.&lt;BR /&gt;NOTE: VARCHAR data type is not supported by the V9 engine. Variable unique_event_name has been&lt;BR /&gt;converted to CHAR data type.&lt;BR /&gt;NOTE: VARCHAR data type is not supported by the V9 engine. Variable page has been converted to CHAR&lt;BR /&gt;data type.&lt;BR /&gt;NOTE: VARCHAR data type is not supported by the V9 engine. Variable redcap_version has been converted&lt;BR /&gt;to CHAR data type.&lt;BR /&gt;NOTE: The import data set has 296037 observations and 7 variables.&lt;BR /&gt;NOTE: WORK.ONE data set was successfully created.&lt;BR /&gt;NOTE: PROCEDURE IMPORT used (Total process time):&lt;BR /&gt;real time 11.24 seconds&lt;BR /&gt;cpu time 11.25 seconds&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;9&lt;BR /&gt;10 proc print data=one (obs=10);&lt;BR /&gt;NOTE: Writing HTML Body file: sashtml.htm&lt;BR /&gt;11 run;&lt;/P&gt;&lt;P&gt;NOTE: There were 10 observations read from the data set WORK.ONE.&lt;BR /&gt;NOTE: PROCEDURE PRINT used (Total process time):&lt;BR /&gt;real time 0.28 seconds&lt;BR /&gt;cpu time 0.15 seconds&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;12&lt;BR /&gt;13 proc contents data=one;&lt;BR /&gt;14 run;&lt;/P&gt;&lt;P&gt;NOTE: PROCEDURE CONTENTS used (Total process time):&lt;BR /&gt;real time 0.01 seconds&lt;BR /&gt;cpu time 0.00 seconds&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;15 %macro comb(idn, pidn, eventn, eventnum, pagen, instancen);&lt;BR /&gt;16 data two;&lt;BR /&gt;17 set one;&lt;BR /&gt;18 if id=&amp;amp;idn and pid=&amp;amp;pidn and unique_event_name=&amp;amp;eventn and event_id=&amp;amp;eventnum and page=&amp;amp;pagen and&lt;BR /&gt;18 ! instance=&amp;amp;instancen&lt;BR /&gt;19 then qi106=cats(redcap_version, "DataEntry/index.php?pid=", &amp;amp;pidn, "&amp;amp;id=", &amp;amp;idn, "&amp;amp;page=",&lt;BR /&gt;19 ! &amp;amp;pagen, "&amp;amp;event_id=", &amp;amp;eventnum, "&amp;amp;instance=", &amp;amp;instancen)&lt;BR /&gt;20 else qi106="";&lt;BR /&gt;21 run;&lt;BR /&gt;22 %mend;&lt;BR /&gt;23 %comb(id, pid, unique_event_name,event_id, page, instance);&lt;BR /&gt;MPRINT(COMB): data two;&lt;BR /&gt;MPRINT(COMB): set one;&lt;BR /&gt;WARNING: Apparent symbolic reference ID not resolved.&lt;BR /&gt;WARNING: Apparent symbolic reference PAGE not resolved.&lt;BR /&gt;WARNING: Apparent symbolic reference EVENT_ID not resolved.&lt;BR /&gt;WARNING: Apparent symbolic reference INSTANCE not resolved.&lt;BR /&gt;NOTE 137-205: Line generated by the invoked macro "COMB".&lt;BR /&gt;2 &amp;amp;eventnum, "&amp;amp;instance=", &amp;amp;instancen) else qi106=""; run;&lt;BR /&gt;----&lt;BR /&gt;22&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *, **, +, -, /, ;, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;,&lt;BR /&gt;=, &amp;gt;, &amp;gt;&amp;lt;, &amp;gt;=, AND, EQ, GE, GT, IN, LE, LT, MAX, MIN, NE, NG, NL, NOT, NOTIN, OR, ^, ^=,&lt;BR /&gt;|, ||, ~, ~=.&lt;/P&gt;&lt;P&gt;NOTE: Line generated by the invoked macro "COMB".&lt;BR /&gt;2 &amp;amp;eventnum, "&amp;amp;instance=", &amp;amp;instancen) else qi106=""; run;&lt;BR /&gt;----&lt;BR /&gt;202&lt;BR /&gt;ERROR 202-322: The option or parameter is not recognized and will be ignored.&lt;/P&gt;&lt;P&gt;MPRINT(COMB): if id=id and pid=pid and unique_event_name=unique_event_name and event_id=event_id&lt;BR /&gt;and page=page and instance=instance then qi106=cats(redcap_version, "DataEntry/index.php?pid=", pid,&lt;BR /&gt;"&amp;amp;id=", id, "&amp;amp;page=", page, "&amp;amp;event_id=", event_id, "&amp;amp;instance=", instance) else qi106="" ;&lt;BR /&gt;MPRINT(COMB): run;&lt;/P&gt;&lt;P&gt;NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).&lt;BR /&gt;1:150 2:50&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;WARNING: The data set WORK.TWO may be incomplete. When this step was stopped there were 0&lt;BR /&gt;observations and 8 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.01 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any thoughts?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 14:04:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902312#M356568</guid>
      <dc:creator>JackZ295</dc:creator>
      <dc:date>2023-11-09T14:04:20Z</dc:date>
    </item>
    <item>
      <title>Re: Having Trouble with Macro Variables in SAS When Including If Then Statements in Data Step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902314#M356569</link>
      <description>&lt;PRE&gt;cats(redcap_version, "DataEntry/index.php?pid=", &amp;amp;pidn, "&amp;amp;id=", &amp;amp;idn, "&amp;amp;page=", &amp;amp;pagen, "&amp;amp;event_id=", &amp;amp;eventnum, "&amp;amp;instance=", &amp;amp;instancen) &lt;/PRE&gt;
&lt;P&gt;There is no macro variable named &amp;amp;id&lt;/P&gt;
&lt;P&gt;There is no macro variable named &amp;amp;page&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and so on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you write out, without macros and without macro variables, what the line that I show above should look like for one call of the macro? In other words, if you were writing the program without macros and without macro variables, what would the line be?&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 14:08:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902314#M356569</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-11-09T14:08:33Z</dc:date>
    </item>
    <item>
      <title>Re: Having Trouble with Macro Variables in SAS When Including If Then Statements in Data Step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902319#M356570</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;, many thanks for your help. If you are referring to&amp;nbsp;&lt;/P&gt;&lt;P&gt;"&amp;amp;id=", etc., those aren't macro variables. Those are strings of text.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what the code would look like without the macro variables. The reason why I am using a macro is because my dataset has over 100,000 observations, and I would have to write 100,000 if-then statements.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data two;
set one;
if id=CAAA001 and pid=12345 and unique_event_name=v01_arm_1 and event_id=48831 and page=cf_consent_form_documentation and instance=1
then qi106=cats(redcap_version, "DataEntry/index.php?pid=", pid, "&amp;amp;id=", id, "&amp;amp;page=", page, "&amp;amp;event_id=", event_id, "&amp;amp;instance=", instance)
else qi106="";
run;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Nov 2023 14:16:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902319#M356570</guid>
      <dc:creator>JackZ295</dc:creator>
      <dc:date>2023-11-09T14:16:20Z</dc:date>
    </item>
    <item>
      <title>Re: Having Trouble with Macro Variables in SAS When Including If Then Statements in Data Step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902325#M356572</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/213376"&gt;@JackZ295&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;, many thanks for your help. If you are referring to&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"&amp;amp;id=", etc., those aren't macro variables. Those are strings of text.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is what the code would look like without the macro variables. The reason why I am using a macro is because my dataset has over 100,000 observations, and I would have to write 100,000 if-then statements.&amp;nbsp;&lt;CODE class=""&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;SAS thinks they are macro variables and can't find them. Why? Because you put an &amp;amp; in front of the variable name.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you don't want them to be macro variables, you should not put &amp;amp; in front of the variable name, and then SAS will think they are not macro variables and then SAS will treat them as text.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With regard to your 100,000 observations, you have to get it to work for one observation first without macros and without macro variables. If you can't get it to work for one observation without macros and without macro variables, then it will not work if you try to turn it into a macro and use macro variables. This is such an important piece of advice I am going to put it red bold letters: &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;get the code to work first for a small example without macros and without macro variables before trying to turn it into a macro&lt;/STRONG&gt;&lt;/FONT&gt;.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 14:23:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902325#M356572</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-11-09T14:23:26Z</dc:date>
    </item>
    <item>
      <title>Re: Having Trouble with Macro Variables in SAS When Including If Then Statements in Data Step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902326#M356573</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;, the code actually does work without the macro variables, but I think I'm subbing in the wrong variables for the macro variables somehow. It does concatenate correctly when I try it for the first observation.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 14:30:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902326#M356573</guid>
      <dc:creator>JackZ295</dc:creator>
      <dc:date>2023-11-09T14:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: Having Trouble with Macro Variables in SAS When Including If Then Statements in Data Step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902327#M356574</link>
      <description>&lt;P&gt;Show me the code that actually works without macros and without macro variables.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 14:32:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902327#M356574</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-11-09T14:32:45Z</dc:date>
    </item>
    <item>
      <title>Re: Having Trouble with Macro Variables in SAS When Including If Then Statements in Data Step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902330#M356577</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;, many thanks for your help. Here is the code that works for the first observation of my dataset:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data two;
set one;
if id="CAAA001" and pid=3357 and unique_event_name="consent_arm_1" and event_id=48831 and page="cf_consent_form_documentation" and instance=1 then qi106=cats(redcap_version, "DataEntry/index.php?pid=", pid, "&amp;amp;id=", id, "&amp;amp;page=", page, "&amp;amp;event_id=", event_id, "&amp;amp;instance=", instance);
else qi106="";
run;


proc print data=two (obs=1); 
run; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Nov 2023 14:46:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902330#M356577</guid>
      <dc:creator>JackZ295</dc:creator>
      <dc:date>2023-11-09T14:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: Having Trouble with Macro Variables in SAS When Including If Then Statements in Data Step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902331#M356578</link>
      <description>&lt;P&gt;Agree with Paige.&amp;nbsp; If you can show the code that works (without macro variables), hopefully along with a small amount of sample data (like data step with CARDS statement to generate 5 rows of data), then we can help you with figuring out how to write a macro to generate that code.&amp;nbsp; Without that, we're guessing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That said, I made a little example that does *something* similar to what you are asking. I don't think this is the answer, but it is the kind of thing you are doing.&amp;nbsp; Note one reason that this is not the answer is that if you call this macro multiple times, it will overwrite the work.two each time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one ;
  input id $7. pidn redcap_version $3. ;
  cards ;
CAAA001 3357 foo 
CAAA002 3358 bar 
;


%macro comb(idn, pidn);
data two; 
  set one; 
  if id=&amp;amp;idn
  then qi106=cats(redcap_version, "DataEntry/index.php?pid=", pidn, '&amp;amp;id=', &amp;amp;idn); 
  else qi106=""; 

  put qi106= ;
run; 
%mend ;

%comb("CAAA001", 3357)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This returns:&lt;/P&gt;
&lt;PRE&gt;qi106=fooDataEntry/index.php?pid=3357&amp;amp;id=CAAA001
qi106=
&lt;/PRE&gt;
&lt;P&gt;But really, if you can give a small amount of sample input data, and describe the output data you want (a new variable with a string with the value .... ), people will be able to help you more.&amp;nbsp; It's rare that you need to write a macro that runs hundreds of times.&amp;nbsp; It could be a case where you could use something more basic, like a merge or SQL join.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 14:48:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902331#M356578</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-11-09T14:48:46Z</dc:date>
    </item>
    <item>
      <title>Re: Having Trouble with Macro Variables in SAS When Including If Then Statements in Data Step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902332#M356579</link>
      <description>&lt;P&gt;It can't possibly work, it refers to a macro variable &amp;amp;id. And in any event, I keep asking for code without macros and without macro variables, as if the problem were only to be solved for one line, and so no need for macros and no need for macro variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Show me the log for this data step (all of the log for this data step) when you run this code.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 14:48:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902332#M356579</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-11-09T14:48:50Z</dc:date>
    </item>
    <item>
      <title>Re: Having Trouble with Macro Variables in SAS When Including If Then Statements in Data Step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902334#M356580</link>
      <description>&lt;P&gt;I think that step can only work if you are ignoring messages in your log about unresolved macro variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does this step work for you:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data two;
set one (obs=5);  *Limit input data, only use obs=5 if you know the records for the if statement are in the first 5 records;
if id="CAAA001" and pid=3357 and unique_event_name="consent_arm_1" and event_id=48831 and page="cf_consent_form_documentation" and instance=1 then qi106=cats(redcap_version, "DataEntry/index.php?pid=", pid, '&amp;amp;id=', id, '&amp;amp;page=', page, '&amp;amp;event_id=', event_id, '&amp;amp;instance=', instance);
else qi106="";&lt;BR /&gt;&lt;BR /&gt;put (id pid unique_event_name event_id page instance redcap_version qi106)(=);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In the above, I used single quotes to prevent the macro processor from trying to resolve macro variables ID, Page, Event_ID, and Instance.&amp;nbsp; This code has no macro variable references.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this code works, please show an example of code that works with two IF statements, and show the full log from running the step so we can see the values you want to generate for qi106.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 14:58:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902334#M356580</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-11-09T14:58:38Z</dc:date>
    </item>
    <item>
      <title>Re: Having Trouble with Macro Variables in SAS When Including If Then Statements in Data Step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902335#M356581</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19879"&gt;@Quentin&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/374215"&gt;@paige2&lt;/a&gt;&amp;nbsp;, many thanks for your help. However,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;, as I was trying to mention, the quoted string that you see isn't a macro variable. It's a quoted string that I'm trying to concatenate with other variables. I will provide a row of sample data with some modifications (modifying the URL as it does lead to a real url).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;/*Importing Final Data Set*/ 
options MSGLEVEL=I;
options validvarname=v7;

proc import out=one
datafile='C:\Users\JAZHU\Desktop\LHC_Links\Sample.xlsx'
DBMS=xlsx replace;
getnames=yes;
run;



data two;
set one;
if id="CAAA001" and pid=3357 and unique_event_name="consent_arm_1
" and event_id=48831 and page="cf_consent_form_documentation" and instance=1
then qi106=cats(redcap_version, "DataEntry/index.php?pid=", pid, "&amp;amp;id=", id, "&amp;amp;page=", page, "&amp;amp;event_id=", event_id, "&amp;amp;instance=", instance);
else qi106="";
run;


proc print data=two (obs=1); 
run; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Please note this is just for one row. It would also work for the other rows, but the values for id, pid, unique_event_name, event_id, page, and instance would differ.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 /*Importing Final Data Set*/&lt;BR /&gt;2 options MSGLEVEL=I;&lt;BR /&gt;3 options validvarname=v7;&lt;BR /&gt;4&lt;BR /&gt;5 proc import out=one&lt;BR /&gt;6 datafile='C:\Users\JAZHU\Desktop\LHC_Links\Sample.xlsx'&lt;BR /&gt;7 DBMS=xlsx replace;&lt;BR /&gt;8 getnames=yes;&lt;BR /&gt;9 run;&lt;/P&gt;&lt;P&gt;NOTE: VARCHAR data type is not supported by the V9 engine. Variable id has been converted to CHAR&lt;BR /&gt;data type.&lt;BR /&gt;NOTE: VARCHAR data type is not supported by the V9 engine. Variable unique_event_name has been&lt;BR /&gt;converted to CHAR data type.&lt;BR /&gt;NOTE: VARCHAR data type is not supported by the V9 engine. Variable page has been converted to CHAR&lt;BR /&gt;data type.&lt;BR /&gt;NOTE: VARCHAR data type is not supported by the V9 engine. Variable redcap_version has been converted&lt;BR /&gt;to CHAR data type.&lt;BR /&gt;NOTE: The import data set has 1 observations and 7 variables.&lt;BR /&gt;NOTE: WORK.ONE data set was successfully created.&lt;BR /&gt;NOTE: PROCEDURE IMPORT used (Total process time):&lt;BR /&gt;real time 0.03 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;10&lt;BR /&gt;11&lt;BR /&gt;12&lt;BR /&gt;13 data two;&lt;BR /&gt;14 set one;&lt;BR /&gt;15 if id="CAAA001" and pid=3357 and unique_event_name="consent_arm_1&lt;BR /&gt;16 " and event_id=48831 and page="cf_consent_form_documentation" and instance=1&lt;BR /&gt;17 then qi106=cats(redcap_version, "DataEntry/index.php?pid=", pid, "&amp;amp;id=", id, "&amp;amp;page=", page,&lt;BR /&gt;17 ! "&amp;amp;event_id=", event_id, "&amp;amp;instance=", instance);&lt;BR /&gt;WARNING: Apparent symbolic reference ID not resolved.&lt;BR /&gt;WARNING: Apparent symbolic reference PAGE not resolved.&lt;BR /&gt;WARNING: Apparent symbolic reference EVENT_ID not resolved.&lt;BR /&gt;WARNING: Apparent symbolic reference INSTANCE not resolved.&lt;BR /&gt;18 else qi106="";&lt;BR /&gt;19 run;&lt;/P&gt;&lt;P&gt;INFO: Character variables have defaulted to a length of 200 at the places given by: (Line):(Column).&lt;BR /&gt;Truncation can result.&lt;BR /&gt;17:6 qi106&lt;BR /&gt;NOTE: There were 1 observations read from the data set WORK.ONE.&lt;BR /&gt;NOTE: The data set WORK.TWO has 1 observations and 8 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.01 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;20&lt;BR /&gt;21&lt;BR /&gt;22 proc print data=two (obs=1);&lt;BR /&gt;NOTE: Writing HTML Body file: sashtml.htm&lt;BR /&gt;23 run;&lt;/P&gt;&lt;P&gt;NOTE: There were 1 observations read from the data set WORK.TWO.&lt;BR /&gt;NOTE: PROCEDURE PRINT used (Total process time):&lt;BR /&gt;real time 0.27 seconds&lt;BR /&gt;cpu time 0.15 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do see in the log that there's that issue of SAS recognizing my text string as a macro variable. Not sure if there's a workaround for it. The text string is part of a URL.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Attached you will find a sample dataset.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 15:05:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902335#M356581</guid>
      <dc:creator>JackZ295</dc:creator>
      <dc:date>2023-11-09T15:05:13Z</dc:date>
    </item>
    <item>
      <title>Re: Having Trouble with Macro Variables in SAS When Including If Then Statements in Data Step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902338#M356583</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19879"&gt;@Quentin&lt;/a&gt;&amp;nbsp;, many thanks for your help. I'll see if this works, but the records for the if statement are all of them. I'm trying to get the if and then statement to apply to all rows, though I guess the 'else qi106=""' statement shouldn't be there, as that would overwrite every role.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 15:10:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902338#M356583</guid>
      <dc:creator>JackZ295</dc:creator>
      <dc:date>2023-11-09T15:10:42Z</dc:date>
    </item>
    <item>
      <title>Re: Having Trouble with Macro Variables in SAS When Including If Then Statements in Data Step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902340#M356584</link>
      <description>&lt;P&gt;Most of us will not download Microsoft Excel (or any Microsoft Office) files as they can be a security threat. The proper way to provide data is via WORKING data step code (&lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;examples and instructions&lt;/A&gt;). However, as far as this problem is concerned, data is irrelevant at this time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It simply does not matter that you think &amp;amp;id is a text string. SAS thinks it is a macro variable, and SAS doesn't know or care that you think it is a text string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What happens if you change all the double quotes to single quotes on that line. Does this produce the desired text string in qi106?&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 15:13:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902340#M356584</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-11-09T15:13:29Z</dc:date>
    </item>
    <item>
      <title>Re: Having Trouble with Macro Variables in SAS When Including If Then Statements in Data Step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902343#M356587</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19879"&gt;@Quentin&lt;/a&gt;&amp;nbsp;, many thanks for your help again. This code works, and here is the code for the first two observations of the sample dataset (see attached).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;/*Importing Final Data Set*/ 
options MSGLEVEL=I;
options validvarname=v7;

proc import out=one
datafile='C:\Users\JAZHU\Desktop\LHC_Links\Sample.xlsx'
DBMS=xlsx replace;
getnames=yes;
run;


data two;
set one;
if id="CAAA001" and pid=3357 and unique_event_name="consent_arm_1" and event_id=48831 and page="cf_consent_form_documentation" and instance=1 then qi106=cats(redcap_version, "DataEntry/index.php?pid=", pid, '&amp;amp;id=', id, '&amp;amp;page=', page, '&amp;amp;event_id=', event_id, '&amp;amp;instance=', instance);;put (id pid unique_event_name event_id page instance redcap_version qi106)(=);
if id="CAAA001" and pid=3357 and unique_event_name="eligibility_arm_1" and event_id=48806 and page="sc_screening_form" and instance=1 then qi106=cats(redcap_version, "DataEntry/index.php?pid=", pid, '&amp;amp;id=', id, '&amp;amp;page=', page, '&amp;amp;event_id=', event_id, '&amp;amp;instance=', instance);;put (id pid unique_event_name event_id page instance redcap_version qi106)(=);
run;

proc print data=two (obs=2);
run; 

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;NOTE: Copyright (c) 2016 by SAS Institute Inc., Cary, NC, USA.&lt;BR /&gt;NOTE: SAS (r) Proprietary Software 9.4 (TS1M7)&lt;BR /&gt;Licensed to J HPKNS UNV-BLOOMBERG SCH OF PUB HLTH DEPT OF EPID, Site 70092145.&lt;BR /&gt;NOTE: This session is executing on the X64_10PRO platform.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: Analytical products:&lt;/P&gt;&lt;P&gt;SAS/STAT 15.2&lt;BR /&gt;SAS/ETS 15.2&lt;BR /&gt;SAS/OR 15.2&lt;BR /&gt;SAS/IML 15.2&lt;BR /&gt;SAS/QC 15.2&lt;/P&gt;&lt;P&gt;NOTE: Additional host information:&lt;/P&gt;&lt;P&gt;X64_10PRO WIN 10.0.19041 Workstation&lt;/P&gt;&lt;P&gt;NOTE: SAS initialization used:&lt;BR /&gt;real time 1.49 seconds&lt;BR /&gt;cpu time 0.95 seconds&lt;/P&gt;&lt;P&gt;1 /*Importing Final Data Set*/&lt;BR /&gt;2 options MSGLEVEL=I;&lt;BR /&gt;3 options validvarname=v7;&lt;BR /&gt;4&lt;BR /&gt;5 proc import out=one&lt;BR /&gt;6 datafile='C:\Users\JAZHU\Desktop\LHC_Links\Sample.xlsx'&lt;BR /&gt;7 DBMS=xlsx replace;&lt;BR /&gt;8 getnames=yes;&lt;BR /&gt;9 run;&lt;/P&gt;&lt;P&gt;NOTE: VARCHAR data type is not supported by the V9 engine. Variable id has been converted to CHAR&lt;BR /&gt;data type.&lt;BR /&gt;NOTE: VARCHAR data type is not supported by the V9 engine. Variable unique_event_name has been&lt;BR /&gt;converted to CHAR data type.&lt;BR /&gt;NOTE: VARCHAR data type is not supported by the V9 engine. Variable page has been converted to CHAR&lt;BR /&gt;data type.&lt;BR /&gt;NOTE: VARCHAR data type is not supported by the V9 engine. Variable redcap_version has been converted&lt;BR /&gt;to CHAR data type.&lt;BR /&gt;NOTE: The import data set has 2 observations and 7 variables.&lt;BR /&gt;NOTE: WORK.ONE data set was successfully created.&lt;BR /&gt;NOTE: PROCEDURE IMPORT used (Total process time):&lt;BR /&gt;real time 0.05 seconds&lt;BR /&gt;cpu time 0.04 seconds&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;10&lt;BR /&gt;11&lt;BR /&gt;12 data two;&lt;BR /&gt;13 set one;&lt;BR /&gt;14 if id="CAAA001" and pid=3357 and unique_event_name="consent_arm_1" and event_id=48831 and&lt;BR /&gt;14 ! page="cf_consent_form_documentation" and instance=1 then qi106=cats(redcap_version,&lt;BR /&gt;14 ! "DataEntry/index.php?pid=", pid, '&amp;amp;id=', id, '&amp;amp;page=', page, '&amp;amp;event_id=', event_id,&lt;BR /&gt;14 ! '&amp;amp;instance=', instance);;put (id pid unique_event_name event_id page instance redcap_version&lt;BR /&gt;14 ! qi106)(=);&lt;BR /&gt;15 if id="CAAA001" and pid=3357 and unique_event_name="eligibility_arm_1" and event_id=48806 and&lt;BR /&gt;15 ! page="sc_screening_form" and instance=1 then qi106=cats(redcap_version,&lt;BR /&gt;15 ! "DataEntry/index.php?pid=", pid, '&amp;amp;id=', id, '&amp;amp;page=', page, '&amp;amp;event_id=', event_id,&lt;BR /&gt;15 ! '&amp;amp;instance=', instance);;put (id pid unique_event_name event_id page instance redcap_version&lt;BR /&gt;15 ! qi106)(=);&lt;BR /&gt;16 run;&lt;/P&gt;&lt;P&gt;INFO: Character variables have defaulted to a length of 200 at the places given by: (Line):(Column).&lt;BR /&gt;Truncation can result.&lt;BR /&gt;14:148 qi106&lt;BR /&gt;id=CAAA001 pid=3357 unique_event_name=consent_arm_1 event_id=48831 page=cf_consent_form_documentation&lt;BR /&gt;instance=1 redcap_version=url&lt;BR /&gt;qi106=urlDataEntry/index.php?pid=3357&amp;amp;id=CAAA001&amp;amp;page=cf_consent_form_documentation&amp;amp;event_id=48831&amp;amp;ins&lt;BR /&gt;tance=1&lt;BR /&gt;id=CAAA001 pid=3357 unique_event_name=consent_arm_1 event_id=48831 page=cf_consent_form_documentation&lt;BR /&gt;instance=1 redcap_version=url&lt;BR /&gt;qi106=urlDataEntry/index.php?pid=3357&amp;amp;id=CAAA001&amp;amp;page=cf_consent_form_documentation&amp;amp;event_id=48831&amp;amp;ins&lt;BR /&gt;tance=1&lt;BR /&gt;id=CAAA001 pid=3357 unique_event_name=eligibility_arm_1 event_id=48806 page=sc_screening_form&lt;BR /&gt;instance=1 redcap_version=url qi106=&lt;BR /&gt;id=CAAA001 pid=3357 unique_event_name=eligibility_arm_1 event_id=48806 page=sc_screening_form&lt;BR /&gt;instance=1 redcap_version=url&lt;BR /&gt;qi106=urlDataEntry/index.php?pid=3357&amp;amp;id=CAAA001&amp;amp;page=sc_screening_form&amp;amp;event_id=48806&amp;amp;instance=1&lt;BR /&gt;NOTE: There were 2 observations read from the data set WORK.ONE.&lt;BR /&gt;NOTE: The data set WORK.TWO has 2 observations and 8 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.05 seconds&lt;BR /&gt;cpu time 0.06 seconds&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;17&lt;BR /&gt;18 proc print data=two (obs=2);&lt;BR /&gt;NOTE: Writing HTML Body file: sashtml.htm&lt;BR /&gt;19 run;&lt;/P&gt;&lt;P&gt;NOTE: There were 2 observations read from the data set WORK.TWO.&lt;BR /&gt;NOTE: PROCEDURE PRINT used (Total process time):&lt;BR /&gt;real time 0.54 seconds&lt;BR /&gt;cpu time 0.39 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 15:21:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902343#M356587</guid>
      <dc:creator>JackZ295</dc:creator>
      <dc:date>2023-11-09T15:21:58Z</dc:date>
    </item>
    <item>
      <title>Re: Having Trouble with Macro Variables in SAS When Including If Then Statements in Data Step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902344#M356588</link>
      <description>&lt;P&gt;From that example, it's not clear if you need an IF statement at all.&amp;nbsp; It looks like you are generating the same string for both pids.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What would you think of:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data two;
set one;
qi106=cats(redcap_version, "DataEntry/index.php?pid=", pid, '&amp;amp;id=', id, '&amp;amp;page=', page, '&amp;amp;event_id=', event_id, '&amp;amp;instance=', instance);
put (id pid unique_event_name event_id page instance redcap_version qi106)(=);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;?&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 15:38:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-with-Macro-Variables-in-SAS-When-Including-If/m-p/902344#M356588</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-11-09T15:38:02Z</dc:date>
    </item>
  </channel>
</rss>

