<?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: Creating subscripted variables in loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-subscripted-variables-in-loop/m-p/13483#M1589</link>
    <description>I am hacking my way through IML. and all I wanted to do was create a series of variables that were subscripted.  &lt;BR /&gt;
&lt;BR /&gt;
Y_i=i&lt;BR /&gt;
&lt;BR /&gt;
I'm translating the code out of Stata and Matlab, where this seems to be an easier thing to do.&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
&lt;BR /&gt;
GT</description>
    <pubDate>Fri, 06 Nov 2009 18:51:01 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-11-06T18:51:01Z</dc:date>
    <item>
      <title>Creating subscripted variables in loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-subscripted-variables-in-loop/m-p/13481#M1587</link>
      <description>I can program this fairly well in Stata, so I am guessing that SAS and IML can do the same thing.  I don't know enough about the SAS language to try and look up the bits and pieces of this in the documentation.&lt;BR /&gt;
&lt;BR /&gt;
Here's the code in Stata:&lt;BR /&gt;
&lt;BR /&gt;
forvalues i=0/4 {&lt;BR /&gt;
gen fakevar_`i'=.&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
The internal variable i will take on values 0-4, and this will generate 5 variables with missing values: fakevar_0...fakevar_4.  Stata will also interpret the `i' as the value within a text string.&lt;BR /&gt;
&lt;BR /&gt;
How do I do this in SAS?  What do you call those internal variables in loops, and how do I get the statements in the loop to use that value of i in the way I want to use it?&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
&lt;BR /&gt;
GT

Message was edited by: Turgidson</description>
      <pubDate>Fri, 06 Nov 2009 18:08:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-subscripted-variables-in-loop/m-p/13481#M1587</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-11-06T18:08:13Z</dc:date>
    </item>
    <item>
      <title>Re: Creating subscripted variables in loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-subscripted-variables-in-loop/m-p/13482#M1588</link>
      <description>Hi:&lt;BR /&gt;
  If you're talking about DATA step programs then SAS can treat those numbered variables as though they are members of an ARRAY. This paper has a good introduction to how ARRAYS work in SAS:&lt;BR /&gt;
&lt;A href="http://support.sas.com/rnd/papers/sgf07/arrays1780.pdf" target="_blank"&gt;http://support.sas.com/rnd/papers/sgf07/arrays1780.pdf&lt;/A&gt;&lt;BR /&gt;
 &lt;BR /&gt;
  Since IML works with matrices, if your real interest is in IML, matrix addressing is different than array addressing. Here's the IML user's guide:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/imlug/59656/PDF/default/imlug.pdf" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/imlug/59656/PDF/default/imlug.pdf&lt;/A&gt; Chapter 4 discusses how to work with IML matrices, including subscripting.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Fri, 06 Nov 2009 18:39:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-subscripted-variables-in-loop/m-p/13482#M1588</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2009-11-06T18:39:53Z</dc:date>
    </item>
    <item>
      <title>Re: Creating subscripted variables in loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-subscripted-variables-in-loop/m-p/13483#M1589</link>
      <description>I am hacking my way through IML. and all I wanted to do was create a series of variables that were subscripted.  &lt;BR /&gt;
&lt;BR /&gt;
Y_i=i&lt;BR /&gt;
&lt;BR /&gt;
I'm translating the code out of Stata and Matlab, where this seems to be an easier thing to do.&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
&lt;BR /&gt;
GT</description>
      <pubDate>Fri, 06 Nov 2009 18:51:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-subscripted-variables-in-loop/m-p/13483#M1589</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-11-06T18:51:01Z</dc:date>
    </item>
    <item>
      <title>Re: Creating subscripted variables in loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-subscripted-variables-in-loop/m-p/13484#M1590</link>
      <description>in a data step you can define subscripted variables in many ways. For example&lt;BR /&gt;
length num1-num25 4;&lt;BR /&gt;
defines 25 short numeric vars.&lt;BR /&gt;
retain chr1 - chr9 "ab" ;&lt;BR /&gt;
defines 9 chrN vars all stsrting with value ;ab</description>
      <pubDate>Sat, 07 Nov 2009 00:27:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-subscripted-variables-in-loop/m-p/13484#M1590</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2009-11-07T00:27:51Z</dc:date>
    </item>
    <item>
      <title>Re: Creating subscripted variables in loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-subscripted-variables-in-loop/m-p/13485#M1591</link>
      <description>FWIW, a separate SAS discussion forum exists for the SAS/IML product.  For what you have described in your post (to some extent), there are two different SAS programming techniques, each with their own purpose to do_over/iterate - mentioned below:&lt;BR /&gt;
&lt;BR /&gt;
DATA step language:&lt;BR /&gt;
&lt;BR /&gt;
DO I=0 TO 4;&lt;BR /&gt;
* your SAS DATA step code goes here. ;&lt;BR /&gt;
END;&lt;BR /&gt;
&lt;BR /&gt;
MACRO language:&lt;BR /&gt;
&lt;BR /&gt;
%DO I=0 %TO 4;&lt;BR /&gt;
%* your SAS macro code goes here. ;&lt;BR /&gt;
%END;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Suggest you start with some basic SAS system reading and go from there - links to SAS support &lt;A href="http://support.sas.com/" target="_blank"&gt;http://support.sas.com/&lt;/A&gt;  website documentation and technical / conference paper references below.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
SAS-hosted DOCUMENTATION references:&lt;BR /&gt;
&lt;BR /&gt;
SAS(R) 9.2 Language Reference: Concepts, DATA Step Processing:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a001281588.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a001281588.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Step-by-Step Programming with Base SAS(R) Software - Introduction to DATA Step Processing&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/a001302699.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/a001302699.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
SAS Macro Language: Reference&lt;BR /&gt;
Introduction to the Macro Facility&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/a002293969.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/a002293969.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
SAS Language Reference by Name, Product, and Category - Macro Statements Syntax Sorted Alphabetically&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/allprodslang/62304/HTML/default/syntaxByType-macroStatement.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/allprodslang/62304/HTML/default/syntaxByType-macroStatement.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
SAS SQL Procedure User's Guide - Introduction to the SQL Procedure&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/sqlproc/62086/HTML/default/a002536894.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/sqlproc/62086/HTML/default/a002536894.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
CONFERENCE PAPER references:&lt;BR /&gt;
&lt;BR /&gt;
A Hands-On Introduction to SAS® DATA Step Programming&lt;BR /&gt;
Debbie Buck, D. B. &amp;amp; P. Associates, Houston, TX  (a SUGI conference paper)&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi30/134-30.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi30/134-30.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Understanding the SAS® DATA Step and the Program Data Vector&lt;BR /&gt;
Steven First, Systems Seminar Consultants, Madison, WI&lt;BR /&gt;
&lt;A href="http://support.sas.com/resources/papers/proceedings09/136-2009.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings09/136-2009.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
SAS Macro Programming for Beginners&lt;BR /&gt;
Susan J. Slaughter, Avocet Solutions, Davis, CA&lt;BR /&gt;
Lora D. Delwiche, Delwiche Consulting, Winters, CA&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi29/243-29.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi29/243-29.pdf&lt;/A&gt;</description>
      <pubDate>Sat, 07 Nov 2009 16:11:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-subscripted-variables-in-loop/m-p/13485#M1591</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-11-07T16:11:46Z</dc:date>
    </item>
  </channel>
</rss>

