<?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: How can add dynamically variables while importing a file? in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/How-can-add-dynamically-variables-while-importing-a-file/m-p/522645#M16173</link>
    <description>&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Basically I have this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="job.png" style="width: 534px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/25808i0B3D0DC8DE530EDE/image-size/large?v=v2&amp;amp;px=999" role="button" title="job.png" alt="job.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What i want to do is to add this macro (it works fine in sas base code), I tryed with a user written code after File Reader&amp;nbsp;but not working&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro ciclo;
%let pos1=285;
%let pos2=286;
%let pos3=289;
%let pos4=296;

%let finciclo=450;
	%do x=1 %to &amp;amp;end%by 1;
	    input
		@&amp;amp;pos1. IB_ACTION_FLAG_&amp;amp;x. $EBCDIC1.
		@&amp;amp;pos2. IB_INST_OCCUR_SEQ_&amp;amp;x. $EBCDIC3. @;
		if not missing(IB_INST_OCCUR_SEQ_&amp;amp;x.) then do;
		  input
		  @&amp;amp;pos3. IB_INST_AMT_&amp;amp;x. S370FPD7.2
		  @&amp;amp;pos4. IB_INST_PRIN_&amp;amp;x. S370FPD7.2;


	%end;
%put &amp;amp;pos1;
%put &amp;amp;pos2;
%put &amp;amp;pos3;

%mend;


data temp2;

%ciclo;

run;
&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;Not sure how can I translate this into DI, any advice?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Names and number positions are dummy for confidentiallity.&lt;/P&gt;</description>
    <pubDate>Wed, 19 Dec 2018 17:36:50 GMT</pubDate>
    <dc:creator>Kal_ETL</dc:creator>
    <dc:date>2018-12-19T17:36:50Z</dc:date>
    <item>
      <title>How can add dynamically variables while importing a file?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-can-add-dynamically-variables-while-importing-a-file/m-p/522620#M16171</link>
      <description>&lt;P&gt;Hello Community,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a couple of text files fixed width. The thing is that it is a business rule that after certain position, all variables should be created dynamically with a numeric consecutive sufix (1,2,3....n). I know n value and positions to read for each one. I did a do loop from 1 to n and works fine (tested in EG with dummy values).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But now I wanted to use my macro after the Filereader doesn't work, I am putting it into a user written code. I think I need to put while reading the files since will extract infor from files.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does anyone has any tip on how to do this, or did something like this in the past?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any example or tip would be great.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Dec 2018 16:24:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-can-add-dynamically-variables-while-importing-a-file/m-p/522620#M16171</guid>
      <dc:creator>Kal_ETL</dc:creator>
      <dc:date>2018-12-19T16:24:31Z</dc:date>
    </item>
    <item>
      <title>Re: How can add dynamically variables while importing a file?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-can-add-dynamically-variables-while-importing-a-file/m-p/522626#M16172</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not sure exactly what your trying to do. Can you please post with some example code or data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Input statemnt can be given as var1-var10 for variables var1,var2,var3,...........var10.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Dec 2018 16:37:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-can-add-dynamically-variables-while-importing-a-file/m-p/522626#M16172</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-12-19T16:37:00Z</dc:date>
    </item>
    <item>
      <title>Re: How can add dynamically variables while importing a file?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-can-add-dynamically-variables-while-importing-a-file/m-p/522645#M16173</link>
      <description>&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Basically I have this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="job.png" style="width: 534px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/25808i0B3D0DC8DE530EDE/image-size/large?v=v2&amp;amp;px=999" role="button" title="job.png" alt="job.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What i want to do is to add this macro (it works fine in sas base code), I tryed with a user written code after File Reader&amp;nbsp;but not working&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro ciclo;
%let pos1=285;
%let pos2=286;
%let pos3=289;
%let pos4=296;

%let finciclo=450;
	%do x=1 %to &amp;amp;end%by 1;
	    input
		@&amp;amp;pos1. IB_ACTION_FLAG_&amp;amp;x. $EBCDIC1.
		@&amp;amp;pos2. IB_INST_OCCUR_SEQ_&amp;amp;x. $EBCDIC3. @;
		if not missing(IB_INST_OCCUR_SEQ_&amp;amp;x.) then do;
		  input
		  @&amp;amp;pos3. IB_INST_AMT_&amp;amp;x. S370FPD7.2
		  @&amp;amp;pos4. IB_INST_PRIN_&amp;amp;x. S370FPD7.2;


	%end;
%put &amp;amp;pos1;
%put &amp;amp;pos2;
%put &amp;amp;pos3;

%mend;


data temp2;

%ciclo;

run;
&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;Not sure how can I translate this into DI, any advice?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Names and number positions are dummy for confidentiallity.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Dec 2018 17:36:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-can-add-dynamically-variables-while-importing-a-file/m-p/522645#M16173</guid>
      <dc:creator>Kal_ETL</dc:creator>
      <dc:date>2018-12-19T17:36:50Z</dc:date>
    </item>
    <item>
      <title>Re: How can add dynamically variables while importing a file?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-can-add-dynamically-variables-while-importing-a-file/m-p/522654#M16174</link>
      <description>I don't see an infile statement in that code. How are you linking it to the data source?</description>
      <pubDate>Wed, 19 Dec 2018 17:55:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-can-add-dynamically-variables-while-importing-a-file/m-p/522654#M16174</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-12-19T17:55:16Z</dc:date>
    </item>
    <item>
      <title>Re: How can add dynamically variables while importing a file?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-can-add-dynamically-variables-while-importing-a-file/m-p/522736#M16176</link>
      <description>&lt;P&gt;You're right.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However I think I solve part of the problem. I put the code into the FileReader using the code generation mode: user writting code. The I added my macro and called it below last field from the input. Something like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data work.W665GGA2 / view = work.W665GGA2 ; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; infile "/SASDATA/staging/filename.TXT"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lrecl = 16464&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; truncover&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; firstobs = 1&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; recfm=f; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;input @ 1&amp;nbsp;field1&amp;nbsp; $EBCDIC19.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @ 20 field2 S370FPD4.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @ 24 field3 S370FPD4.&lt;/P&gt;
&lt;P&gt;%macrocall that add variables dynamically;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It worked fine, but&amp;nbsp; now I don't know why it is loading only the half, since log says:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOTE: There were 45800 observations read from the data set WORK.W665W02N.&lt;BR /&gt;NOTE: 45800 observations added.&lt;BR /&gt;NOTE: The data set STG_TE_NB_M has 45800 observations and 3197 variables.&lt;BR /&gt;NOTE: 91600 records were read from the infile "/SASDATA/staging/filename.TXT".&lt;/P&gt;</description>
      <pubDate>Wed, 19 Dec 2018 22:49:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-can-add-dynamically-variables-while-importing-a-file/m-p/522736#M16176</guid>
      <dc:creator>Kal_ETL</dc:creator>
      <dc:date>2018-12-19T22:49:59Z</dc:date>
    </item>
    <item>
      <title>Re: How can add dynamically variables while importing a file?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-can-add-dynamically-variables-while-importing-a-file/m-p/522740#M16177</link>
      <description>Are you certain on your LRECL setting?</description>
      <pubDate>Wed, 19 Dec 2018 22:57:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-can-add-dynamically-variables-while-importing-a-file/m-p/522740#M16177</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-12-19T22:57:42Z</dc:date>
    </item>
    <item>
      <title>Re: How can add dynamically variables while importing a file?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-can-add-dynamically-variables-while-importing-a-file/m-p/522798#M16181</link>
      <description>&lt;P&gt;Hello Reeza,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;No I'm not. Those are files from Mainframe. How can i know the correct lrecl? I was trying differente but always load the half of the read from file.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Dec 2018 05:08:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-can-add-dynamically-variables-while-importing-a-file/m-p/522798#M16181</guid>
      <dc:creator>Kal_ETL</dc:creator>
      <dc:date>2018-12-20T05:08:24Z</dc:date>
    </item>
    <item>
      <title>Re: How can add dynamically variables while importing a file?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-can-add-dynamically-variables-while-importing-a-file/m-p/522819#M16183</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/7559"&gt;@Kal_ETL&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro ciclo;
%let pos1=285;
%let pos2=286;
%let pos3=289;
%let pos4=296;

%let finciclo=450;
	%do x=1 %to &amp;amp;end%by 1;
	    input
		@&amp;amp;pos1. IB_ACTION_FLAG_&amp;amp;x. $EBCDIC1.
		@&amp;amp;pos2. IB_INST_OCCUR_SEQ_&amp;amp;x. $EBCDIC3. @;
		if not missing(IB_INST_OCCUR_SEQ_&amp;amp;x.) then do;
		  input
		  @&amp;amp;pos3. IB_INST_AMT_&amp;amp;x. S370FPD7.2
		  @&amp;amp;pos4. IB_INST_PRIN_&amp;amp;x. S370FPD7.2;


	%end;
%put &amp;amp;pos1;
%put &amp;amp;pos2;
%put &amp;amp;pos3;

%mend;


data temp2;

%ciclo;

run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You use &amp;amp;end, which is nowhere defined.&lt;/P&gt;
&lt;P&gt;You do not change the positions within the %do loop, so you will always read the same content.&lt;/P&gt;
&lt;P&gt;The second input statement in the %do loop does not have a line hold (@), so the next input will read from the next line in the infile.&lt;/P&gt;
&lt;P&gt;If &amp;amp;end were 2, you would therefore get only half the expected observations.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Dec 2018 09:25:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-can-add-dynamically-variables-while-importing-a-file/m-p/522819#M16183</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-12-20T09:25:03Z</dc:date>
    </item>
    <item>
      <title>Re: How can add dynamically variables while importing a file?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-can-add-dynamically-variables-while-importing-a-file/m-p/522821#M16184</link>
      <description>&lt;P&gt;Note that reading a certain structure multiple times can be done without macro processing in a data step do loop:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
array x1{8} $1;
array x2{8} 8;
do i = 1 to 8;
  input
    @((i-1)*2+1) x1{i} $1.
    @((i-1)*2+2) x2{i} 1.
    @
  ;
end;
cards;
A1B2C3D4E5F6G7H8
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Dec 2018 09:44:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-can-add-dynamically-variables-while-importing-a-file/m-p/522821#M16184</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-12-20T09:44:36Z</dc:date>
    </item>
    <item>
      <title>Re: How can add dynamically variables while importing a file?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-can-add-dynamically-variables-while-importing-a-file/m-p/522944#M16185</link>
      <description>&lt;P&gt;You are right, but I don't know why it is bad copied. &amp;amp;end should be the macrovariable before that line: finciclo, declared to 450.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is complete and correct macro, honestly this code was previously developed and nobody knows exactly the business rule in order to rebuild or optimize it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro ciclo;
%let pos1=265;
%let pos2=266;
%let pos3=269;
%let pos4=276;
%let pos5=283;
%let pos6=290;
%let pos7=297;

%let finciclo=450;
	%do x=1 %to &amp;amp;finciclo %by 1;
	    input
		@&amp;amp;pos1. NTIB_IB_ACTION_FLAG_&amp;amp;x. $EBCDIC1.
		@&amp;amp;pos2. NTIB_IB_INST_OCCUR_SEQ_&amp;amp;x. $EBCDIC3. @;
		if not missing(NTIB_IB_INST_OCCUR_SEQ_&amp;amp;x.) then do;
		  input
		  @&amp;amp;pos3. NTIB_IB_INST_AMT_&amp;amp;x. S370FPD7.2
		  @&amp;amp;pos4. NTIB_IB_INST_PRIN_&amp;amp;x. S370FPD7.2
		  @&amp;amp;pos5. NTIB_IB_INST_INT_&amp;amp;x. S370FPD7.2
		  @&amp;amp;pos6. NTIB_IB_INST_FEE_&amp;amp;x. S370FPD7.2
		  @&amp;amp;pos7. NTIB_IB_INST_RELEASE_DATN_&amp;amp;x. S370FPD4.0 @;

         %CNVDATE(NTIB_IB_INST_RELEASE_DATN_&amp;amp;x. , julndt,sdtout=NTIB_IB_INST_RELEASE_DATE_&amp;amp;x. );

         %if &amp;amp;x=2 %then ;;

	     %let pos1=&amp;amp;pos1+36;
         %let pos2=&amp;amp;pos2+36;
         %let pos3=&amp;amp;pos3+36;
         %let pos4=&amp;amp;pos4+36;
         %let pos5=&amp;amp;pos5+36;
         %let pos6=&amp;amp;pos6+36;	
         %let pos7=&amp;amp;pos7+36;
	%end;
	%do x=1 %to &amp;amp;finciclo %by 1;
			end;
	%end;
%put &amp;amp;pos1;
%put &amp;amp;pos2;
%put &amp;amp;pos3;

%mend;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Dec 2018 19:43:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-can-add-dynamically-variables-while-importing-a-file/m-p/522944#M16185</guid>
      <dc:creator>Kal_ETL</dc:creator>
      <dc:date>2018-12-20T19:43:13Z</dc:date>
    </item>
    <item>
      <title>Re: How can add dynamically variables while importing a file?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-can-add-dynamically-variables-while-importing-a-file/m-p/522963#M16186</link>
      <description>&lt;P&gt;Good advice, thank you for sharing this. It works great!&lt;/P&gt;</description>
      <pubDate>Thu, 20 Dec 2018 21:19:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-can-add-dynamically-variables-while-importing-a-file/m-p/522963#M16186</guid>
      <dc:creator>Kal_ETL</dc:creator>
      <dc:date>2018-12-20T21:19:32Z</dc:date>
    </item>
    <item>
      <title>Re: How can add dynamically variables while importing a file?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-can-add-dynamically-variables-while-importing-a-file/m-p/523020#M16187</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/7559"&gt;@Kal_ETL&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro ciclo;
%let pos1=265;
%let pos2=266;
%let pos3=269;
%let pos4=276;
%let pos5=283;
%let pos6=290;
%let pos7=297;

%let finciclo=450;
	%do x=1 %to &amp;amp;finciclo %by 1;
	    input
		@&amp;amp;pos1. NTIB_IB_ACTION_FLAG_&amp;amp;x. $EBCDIC1.
		@&amp;amp;pos2. NTIB_IB_INST_OCCUR_SEQ_&amp;amp;x. $EBCDIC3. @;
		if not missing(NTIB_IB_INST_OCCUR_SEQ_&amp;amp;x.) then do;
		  input
		  @&amp;amp;pos3. NTIB_IB_INST_AMT_&amp;amp;x. S370FPD7.2
		  @&amp;amp;pos4. NTIB_IB_INST_PRIN_&amp;amp;x. S370FPD7.2
		  @&amp;amp;pos5. NTIB_IB_INST_INT_&amp;amp;x. S370FPD7.2
		  @&amp;amp;pos6. NTIB_IB_INST_FEE_&amp;amp;x. S370FPD7.2
		  @&amp;amp;pos7. NTIB_IB_INST_RELEASE_DATN_&amp;amp;x. S370FPD4.0 @;

         %CNVDATE(NTIB_IB_INST_RELEASE_DATN_&amp;amp;x. , julndt,sdtout=NTIB_IB_INST_RELEASE_DATE_&amp;amp;x. );

         %if &amp;amp;x=2 %then ;;

	     %let pos1=&amp;amp;pos1+36;
         %let pos2=&amp;amp;pos2+36;
         %let pos3=&amp;amp;pos3+36;
         %let pos4=&amp;amp;pos4+36;
         %let pos5=&amp;amp;pos5+36;
         %let pos6=&amp;amp;pos6+36;	
         %let pos7=&amp;amp;pos7+36;
	%end;
	%do x=1 %to &amp;amp;finciclo %by 1;
			end;
	%end;
%put &amp;amp;pos1;
%put &amp;amp;pos2;
%put &amp;amp;pos3;

%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What will this macro do?&lt;/P&gt;
&lt;P&gt;What first hits my eye are staments like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let pos1=&amp;amp;pos1+36;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The macro preprocessor does not do calculations on its own (with exceptions in %if statements), so &amp;amp;pos1 will end up as&lt;/P&gt;
&lt;PRE&gt;265+36+36+36+(in the end, 450 times "+36");&lt;/PRE&gt;
&lt;P&gt;The preprocessor is just a &lt;EM&gt;code generator&lt;/EM&gt;, nothing more!&lt;/P&gt;
&lt;P&gt;Much better would be&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let pos1=%eval(&amp;amp;pos1+36);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which forces an immediate calculation.&lt;/P&gt;
&lt;P&gt;Then I played "macro processor" for you, and "ran" the core of the macro for 2 iterations. The resulting code would look like this (with some formatiing done by me to reveal the structure):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input
  @265 NTIB_IB_ACTION_FLAG_1 $EBCDIC1.
  @266 NTIB_IB_INST_OCCUR_SEQ_1 $EBCDIC3. @
;
if not missing(NTIB_IB_INST_OCCUR_SEQ_1)
then do;
  input
    @269 NTIB_IB_INST_AMT_1 S370FPD7.2
    @276 NTIB_IB_INST_PRIN_1 S370FPD7.2
    @283 NTIB_IB_INST_INT_1 S370FPD7.2
    @290 NTIB_IB_INST_FEE_1 S370FPD7.2
    @297 NTIB_IB_INST_RELEASE_DATN_1 S370FPD4.0 @
  ;
  input
    @301 NTIB_IB_ACTION_FLAG_2 $EBCDIC1.
    @302 NTIB_IB_INST_OCCUR_SEQ_2 $EBCDIC3. @
  ;
  if not missing(NTIB_IB_INST_OCCUR_SEQ_2)
  then do;
    input
      @305 NTIB_IB_INST_AMT_2 S370FPD7.2
      @312 NTIB_IB_INST_PRIN_2 S370FPD7.2
      @319 NTIB_IB_INST_INT_2 S370FPD7.2
      @326 NTIB_IB_INST_FEE_2 S370FPD7.2
      @333 NTIB_IB_INST_RELEASE_DATN_2 S370FPD4.0 @
    ;
  end;
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can see that the whole input of the "2" variables is dependent on the if condition for the "1" variables. This will of course perpetuate for all variable groups from 2 to 450 in your original macro. The first time NTIB_IB_INST_OCCUR_SEQ_x is missing, the whole input processing is terminated. Is this what you want?&lt;/P&gt;
&lt;P&gt;If this is actually done deliberately, because you could have only missing values from a certain point on, I would also STRONGLY recommend to not store all these variables in one observation, but create a vertical dataset with one observation per variable group. That way you don't waste space for all those missing values.&lt;/P&gt;
&lt;P&gt;My original suggestion would then change to&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
do i = 1 to 8;
  input
    x1 $1.
    x2 1.
    @
  ;
  if not missing(x2) then output;
end;
cards;
A1B2C3D4E5F6G7H8
A1B2C3
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;See how the code is much simpler?&lt;/P&gt;</description>
      <pubDate>Fri, 21 Dec 2018 08:05:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-can-add-dynamically-variables-while-importing-a-file/m-p/523020#M16187</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-12-21T08:05:34Z</dc:date>
    </item>
    <item>
      <title>Re: How can add dynamically variables while importing a file?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-can-add-dynamically-variables-while-importing-a-file/m-p/523069#M16188</link>
      <description>&lt;P&gt;I'm glad you found some useful info, &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/7559"&gt;@Kal_ETL&lt;/a&gt;! If one of the replies was the exact solution to your problem, can you "Accept it as a solution"? Or if one was particularly helpful, feel free to "Like" it. This will help other community members who may run into the same issue know what worked.&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;BR /&gt;Anna&lt;/P&gt;</description>
      <pubDate>Fri, 21 Dec 2018 14:15:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-can-add-dynamically-variables-while-importing-a-file/m-p/523069#M16188</guid>
      <dc:creator>AnnaBrown</dc:creator>
      <dc:date>2018-12-21T14:15:51Z</dc:date>
    </item>
  </channel>
</rss>

