<?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: Problems with PUTVARN() and LOCATEN() in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35159#M8646</link>
    <description>yes, but the problem is, that table2 CAN contain the data but obligatory... so the code will exit with an error if it cant find the name in the table. thats why I step through the names and check, if the particular name must be translated or not.&lt;BR /&gt;
&lt;BR /&gt;
or am I wrong?&lt;BR /&gt;
&lt;BR /&gt;
Tom</description>
    <pubDate>Wed, 17 Nov 2010 16:52:39 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2010-11-17T16:52:39Z</dc:date>
    <item>
      <title>Problems with PUTVARN() and LOCATEN()</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35135#M8622</link>
      <description>hello,&lt;BR /&gt;
&lt;BR /&gt;
after several hours of working I am somehow desperated. &lt;BR /&gt;
&lt;BR /&gt;
I need to change entries of a table (table1) depending on the settings in another table (table2). so far so good, first I decided to check for the specific value in table2 with the command LOCATEN(). the SAS system returned with the error that it doesnt know the function LOCATEN(). &lt;BR /&gt;
&lt;BR /&gt;
well... I thought many ways lead to Rome, so I redesigned it and created an array in table1 with the settings from table2 (because GETVARN() was working)... but now, when I try to change the value with call PUTVARN(), then the SAS system returns with the same error: unknown routine. &lt;BR /&gt;
&lt;BR /&gt;
there is no information about that problem in the help system, only that both functions (LOCATEN() and PUTVARN()) are available... but I dont know why both are not working.&lt;BR /&gt;
&lt;BR /&gt;
Any help is appreciated</description>
      <pubDate>Tue, 16 Nov 2010 16:54:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35135#M8622</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-11-16T16:54:27Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with PUTVARN() and LOCATEN()</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35136#M8623</link>
      <description>Suggest you share your SAS code, also paste the SAS log output where you are getting the error.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Tue, 16 Nov 2010 16:58:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35136#M8623</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-11-16T16:58:13Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with PUTVARN() and LOCATEN()</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35137#M8624</link>
      <description>&lt;U&gt;this is the code sniplet:&lt;BR /&gt;
&lt;/U&gt;&lt;BR /&gt;
data _null_;&lt;BR /&gt;
  &lt;BR /&gt;
  array mname_trans[200] $ mnametrans1-mnametrans200;&lt;BR /&gt;
  &lt;BR /&gt;
  ntrans = 0;&lt;BR /&gt;
&lt;BR /&gt;
  dsid = OPEN( 'merk' );&lt;BR /&gt;
  nobs = ATTRN( dsid, 'NOBS' );&lt;BR /&gt;
  &lt;BR /&gt;
  do i=1 to nobs;&lt;BR /&gt;
    rc = fetchobs( dsid, i );&lt;BR /&gt;
    mname = getvarc( dsid, VARNUM( dsid, 'NAME' ) );&lt;BR /&gt;
    mmethod = getvarc( dsid, VARNUM( dsid, 'METHODE' ) );&lt;BR /&gt;
    if mmethod eq 'S%' then&lt;BR /&gt;
      do;&lt;BR /&gt;
        ntrans = ntrans + 1;&lt;BR /&gt;
        mname_trans[ntrans] = mname;&lt;BR /&gt;
      end;&lt;BR /&gt;
  end;&lt;BR /&gt;
  &lt;BR /&gt;
  rc=CLOSE( dsid );&lt;BR /&gt;
  &lt;BR /&gt;
  dsid = OPEN( 'V_Daten' );&lt;BR /&gt;
  nobs = ATTRN( dsid, 'NOBS' );&lt;BR /&gt;
  nvar = ATTRN( dsid, 'NVARS' );&lt;BR /&gt;
  &lt;BR /&gt;
  do i=1 to nvar;&lt;BR /&gt;
&lt;BR /&gt;
    vname = VARNAME( dsid, i );&lt;BR /&gt;
&lt;BR /&gt;
    do k=1 to ntrans;&lt;BR /&gt;
    &lt;BR /&gt;
	  if ( mname_trans&lt;K&gt; eq vname ) then do;&lt;BR /&gt;
	&lt;BR /&gt;
	    do j=1 to nobs;&lt;BR /&gt;
&lt;BR /&gt;
		  rc = fetchobs( dsid, j );&lt;BR /&gt;
	      value = GETVARN( dsid, i );&lt;BR /&gt;
&lt;BR /&gt;
	      if value le 10.0 then value = 1;&lt;BR /&gt;
	      else if value le 20.0 then value = 2;&lt;BR /&gt;
	      else if value le 30.0 then value = 3;&lt;BR /&gt;
		  else if value le 40.0 then value = 4;&lt;BR /&gt;
		  else if value le 50.0 then value = 5;&lt;BR /&gt;
		  else if value le 60.0 then value = 6;&lt;BR /&gt;
		  else if value le 70.0 then value = 7;&lt;BR /&gt;
		  else if value le 80.0 then value = 8;&lt;BR /&gt;
		  else value = 9;&lt;BR /&gt;
		  &lt;BR /&gt;
		  call putvarn( dsid, i, value );&lt;BR /&gt;
		  &lt;BR /&gt;
		end;&lt;BR /&gt;
		&lt;BR /&gt;
		leave; /* tanslation found, leave do loop */&lt;BR /&gt;
		&lt;BR /&gt;
	  end;&lt;BR /&gt;
	  &lt;BR /&gt;
	end;&lt;BR /&gt;
	&lt;BR /&gt;
  end;&lt;BR /&gt;
  &lt;BR /&gt;
  rc=CLOSE( dsid );&lt;BR /&gt;
  &lt;BR /&gt;
  keep [KFAKTOR1] [KORT] [KJAHR] [ADICH] [AWDA] [AFUS_B] [APHYPZE_B] [AM_NWI2];&lt;BR /&gt;
&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;U&gt;and this is what SAS returns:&lt;/U&gt;&lt;BR /&gt;
&lt;BR /&gt;
665        	      if value le 10.0 then value = 1;&lt;BR /&gt;
666        	      else if value le 20.0 then value = 2;&lt;BR /&gt;
667        	      else if value le 30.0 then value = 3;&lt;BR /&gt;
668        		  else if value le 40.0 then value = 4;&lt;BR /&gt;
669        		  else if value le 50.0 then value = 5;&lt;BR /&gt;
670        		  else if value le 60.0 then value = 6;&lt;BR /&gt;
671        		  else if value le 70.0 then value = 7;&lt;BR /&gt;
672        		  else if value le 80.0 then value = 8;&lt;BR /&gt;
673        		  else value = 9;&lt;BR /&gt;
674        		&lt;BR /&gt;
675        		  call putvarn( dsid, i, value );&lt;BR /&gt;
                    _______&lt;BR /&gt;
                    _______&lt;BR /&gt;
                    _______&lt;BR /&gt;
                    251&lt;BR /&gt;
                    251&lt;BR /&gt;
                    251&lt;BR /&gt;
FEHLER 251-185: Die Subroutine PUTVARN ist unbekannt oder nicht verfügbar. Prüfen Sie die &lt;I&gt;(=&amp;gt; translation: the subroutine PUTVARN is either unknown or not available. check the)&lt;/I&gt;&lt;BR /&gt;
FEHLER 251-185: Die Subroutine PUTVARN ist unbekannt oder nicht verfügbar. Prüfen Sie die &lt;BR /&gt;
FEHLER 251-185: Die Subroutine PUTVARN ist unbekannt oder nicht verfügbar. Prüfen Sie die &lt;BR /&gt;
                Schreibweise. &lt;I&gt;(=&amp;gt; translation: spelling)&lt;/I&gt;&lt;BR /&gt;
                Schreibweise. &lt;BR /&gt;
                Schreibweise. &lt;BR /&gt;
                Entweder wurde sie nicht im Pfad ausführbarer Images gefunden oder &lt;I&gt;(=&amp;gt;translation: either it wasnd found in the path of executable images or)&lt;/I&gt;&lt;BR /&gt;
                Entweder wurde sie nicht im Pfad ausführbarer Images gefunden oder &lt;BR /&gt;
                Entweder wurde sie nicht im Pfad ausführbarer Images gefunden oder &lt;BR /&gt;
                falsche/unvollständige Informationen über den Subroutinendeskriptor lagen vor.&lt;I&gt; (=&amp;gt; translation: wrong/incomplete information about the subroutine descriptor were available)&lt;/I&gt;&lt;BR /&gt;
                falsche/unvollständige Informationen über den Subroutinendeskriptor lagen vor.&lt;BR /&gt;
                falsche/unvollständige Informationen über den Subroutinendeskriptor lagen vor.&lt;/K&gt;</description>
      <pubDate>Tue, 16 Nov 2010 17:25:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35137#M8624</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-11-16T17:25:33Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with PUTVARN() and LOCATEN()</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35138#M8625</link>
      <description>&lt;U&gt;this is another test I ran for the LOCATEN() problem:&lt;/U&gt;&lt;BR /&gt;
&lt;BR /&gt;
76   data test;&lt;BR /&gt;
77     array tab[10] tab1-tab10;&lt;BR /&gt;
78     do i=1 to 10;&lt;BR /&gt;
79       tab&lt;I&gt; = i;&lt;BR /&gt;
80     end;&lt;BR /&gt;
81   run;&lt;BR /&gt;
82&lt;BR /&gt;
83   proc print data=test;&lt;BR /&gt;
84   run;&lt;BR /&gt;
85&lt;BR /&gt;
86   data test2;&lt;BR /&gt;
87     set test;&lt;BR /&gt;
88&lt;BR /&gt;
89     id = OPEN( 'test' );&lt;BR /&gt;
90     row = locaten( id, varnum( id, 'tab1'), 1 );&lt;BR /&gt;
             -------&lt;BR /&gt;
             68&lt;BR /&gt;
FEHLER 68-185: Funktion LOCATEN ist unbekannt oder nicht ausführbar. &lt;I&gt;(same error: unknown funciton)&lt;/I&gt;&lt;BR /&gt;
&lt;BR /&gt;
91   run;&lt;/I&gt;</description>
      <pubDate>Tue, 16 Nov 2010 17:31:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35138#M8625</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-11-16T17:31:37Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with PUTVARN() and LOCATEN()</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35139#M8626</link>
      <description>this is the SAS version I am running: SAS 9.1.3 Service Pack 1</description>
      <pubDate>Tue, 16 Nov 2010 17:38:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35139#M8626</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-11-16T17:38:28Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with PUTVARN() and LOCATEN()</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35140#M8627</link>
      <description>base SAS cannot use scl-type function OPEN() to open dataset for output. Check the function in base SAS Language Reference. &lt;BR /&gt;
Why use these functions - it looks harder than base SAS?&lt;BR /&gt;
Alternatively, use SAS/AF directly with compiled SCL instead of the base SAS environment. Then modify your OPEN() for output. &lt;BR /&gt;
 &lt;BR /&gt;
Good luck&lt;BR /&gt;
peterC</description>
      <pubDate>Tue, 16 Nov 2010 17:44:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35140#M8627</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-11-16T17:44:12Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with PUTVARN() and LOCATEN()</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35141#M8628</link>
      <description>I believe you are attempting to use SAS Component Language (SCL) elements in your program, which are not available.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
SAS(R) Component Language 9.2: Reference, Introduction:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/sclref/59578/HTML/default/a000308113.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/sclref/59578/HTML/default/a000308113.htm&lt;/A&gt;</description>
      <pubDate>Tue, 16 Nov 2010 17:45:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35141#M8628</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-11-16T17:45:01Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with PUTVARN() and LOCATEN()</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35142#M8629</link>
      <description>thank you for the answers, although they do not help me very much &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
Basically I am a C++ developper whom was given the task to write a SAS skript that is called from a PiafSTAT program (which is a German analytical tool for research). So in the end I am a bloody newby with SAS who has no problems with open, close, get and put commands, but got problems with thinking in the SAS way.&lt;BR /&gt;
&lt;BR /&gt;
Well, back to topic: I wonder, wy the SCL-command GETVARN() is working and PUTVARN() not, as both are contents of the SCL-language.&lt;BR /&gt;
&lt;BR /&gt;
and I have no clue how to activate the SCL-language.&lt;BR /&gt;
&lt;BR /&gt;
@peter: I have no clue about SAS/AF and fear, that the combination of PiafSTAT and SAS doesnt let me choose the envirenment. And I dont hava a clue how to check for the function for PUTVARN() in base SAS language. I worked the whole days through the help system but couldnt find it. So I hope to get help here in the forum.</description>
      <pubDate>Tue, 16 Nov 2010 18:03:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35142#M8629</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-11-16T18:03:40Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with PUTVARN() and LOCATEN()</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35143#M8630</link>
      <description>Hello Saracaeus,&lt;BR /&gt;
&lt;BR /&gt;
You said "I need to change entries of a table (table1) depending on the settings in another table (table2)". This sounds too general. If you could give an example of tables 1 and 2 and what would you like to achieve, then it would be much easier to help you with SAS code.&lt;BR /&gt;
&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Tue, 16 Nov 2010 18:34:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35143#M8630</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2010-11-16T18:34:51Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with PUTVARN() and LOCATEN()</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35144#M8631</link>
      <description>table1 contains test data... but some of them are given in % (0-100) =&amp;gt; method "S%" and some of them are given in marks (1-9) =&amp;gt; method "BON19"&lt;BR /&gt;
&lt;BR /&gt;
table2 specifies the method of the data.&lt;BR /&gt;
&lt;BR /&gt;
here an example:&lt;BR /&gt;
&lt;BR /&gt;
table1&lt;BR /&gt;
&lt;BR /&gt;
year   density1 density2 ..... densityX&lt;BR /&gt;
=============================&lt;BR /&gt;
2004  100         2                  56&lt;BR /&gt;
2005  89           4                  78&lt;BR /&gt;
2006  45           7                  98&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
table2:&lt;BR /&gt;
&lt;BR /&gt;
name          method&lt;BR /&gt;
================&lt;BR /&gt;
density1     S%&lt;BR /&gt;
density2     BON19&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
densityX     S%&lt;BR /&gt;
&lt;BR /&gt;
in the final working table all data must be stored as marks, the translation mechanism is the following:&lt;BR /&gt;
&lt;BR /&gt;
percentage        mark&lt;BR /&gt;
=================&lt;BR /&gt;
le 10%             1&lt;BR /&gt;
le 20%              2&lt;BR /&gt;
le 30%              3&lt;BR /&gt;
le 40%              4&lt;BR /&gt;
le 50%              5&lt;BR /&gt;
le 60%              6&lt;BR /&gt;
le 70%              7&lt;BR /&gt;
le 80%              8&lt;BR /&gt;
gt 80%               9&lt;BR /&gt;
&lt;BR /&gt;
so I need to recalculate all these columns that are stored in %.&lt;BR /&gt;
&lt;BR /&gt;
during runtime it decides, what and how many data I get. the colmun names are not always density1 ... densityX... they can vary... they are available in a special symbol (e.g. [ANAMES]), this symbol is translated by PiafSTAT to the real names =&amp;gt; [ANAMES] will be resolved to: "density1 density2 density3 density4" ). so if you write "BY [ANAMES];" ... =&amp;gt; then SAS will see: "BY density1 density2 density3 density4;"&lt;BR /&gt;
&lt;BR /&gt;
I hope I explained clear enough.&lt;BR /&gt;
&lt;BR /&gt;
I work since 20 hours at this problem. As a c++ developper I have a complete different way of thinking, I fear, I am desperating with that small problem.&lt;BR /&gt;
&lt;BR /&gt;
Thank you for any help,&lt;BR /&gt;
Tom</description>
      <pubDate>Tue, 16 Nov 2010 18:55:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35144#M8631</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-11-16T18:55:38Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with PUTVARN() and LOCATEN()</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35145#M8632</link>
      <description>... and the irony is: if PUTVAR() would work, I would have solved this problem already &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;</description>
      <pubDate>Tue, 16 Nov 2010 19:06:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35145#M8632</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-11-16T19:06:06Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with PUTVARN() and LOCATEN()</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35146#M8633</link>
      <description>Hello Saraceus,&lt;BR /&gt;
&lt;BR /&gt;
This is the code for your task if I understood it corretly:&lt;BR /&gt;
[pre]&lt;BR /&gt;
/* Writing name and method values into macro variables */;&lt;BR /&gt;
proc SQL noprint;&lt;BR /&gt;
  select COUNT(*) into :n from table2;&lt;BR /&gt;
  %let n=%trim(&amp;amp;n);&lt;BR /&gt;
  select name   into :d1-:d&amp;amp;n from table2;&lt;BR /&gt;
  select method into :m1-:m&amp;amp;n from table2;&lt;BR /&gt;
quit;&lt;BR /&gt;
/* Final results are in variables r1-r&amp;amp;n */;&lt;BR /&gt;
%macro a;&lt;BR /&gt;
%local i;&lt;BR /&gt;
data r (drop=i);&lt;BR /&gt;
  set table1;&lt;BR /&gt;
  %do i=1 %to &amp;amp;n;&lt;BR /&gt;
    /* Checking method */&lt;BR /&gt;
    if UPCASE("&amp;amp;&amp;amp;m&amp;amp;i") = "S%" then do;&lt;BR /&gt;
      if             &amp;amp;&amp;amp;d&amp;amp;i &amp;lt;= 10 then r&amp;amp;i=1;&lt;BR /&gt;
      else if 10 &amp;lt; &amp;amp;&amp;amp;d&amp;amp;i &amp;lt;= 20 then r&amp;amp;i=2;&lt;BR /&gt;
      else if 20 &amp;lt; &amp;amp;&amp;amp;d&amp;amp;i &amp;lt;= 30 then r&amp;amp;i=3;&lt;BR /&gt;
      else if 30 &amp;lt; &amp;amp;&amp;amp;d&amp;amp;i &amp;lt;= 40 then r&amp;amp;i=4;&lt;BR /&gt;
      else if 40 &amp;lt; &amp;amp;&amp;amp;d&amp;amp;i &amp;lt;= 50 then r&amp;amp;i=5;&lt;BR /&gt;
      else if 50 &amp;lt; &amp;amp;&amp;amp;d&amp;amp;i &amp;lt;= 60 then r&amp;amp;i=6;&lt;BR /&gt;
      else if 60 &amp;lt; &amp;amp;&amp;amp;d&amp;amp;i &amp;lt;= 70 then r&amp;amp;i=7;&lt;BR /&gt;
      else if 60 &amp;lt; &amp;amp;&amp;amp;d&amp;amp;i &amp;lt;= 80 then r&amp;amp;i=8;&lt;BR /&gt;
      else if 80 &amp;lt; &amp;amp;&amp;amp;d&amp;amp;i         then r&amp;amp;i=9;&lt;BR /&gt;
    end;&lt;BR /&gt;
    else r&amp;amp;i=&amp;amp;&amp;amp;d&amp;amp;i;&lt;BR /&gt;
  %end; &lt;BR /&gt;
run;&lt;BR /&gt;
%mend;&lt;BR /&gt;
%a[/pre]&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Tue, 16 Nov 2010 20:05:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35146#M8633</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2010-11-16T20:05:55Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with PUTVARN() and LOCATEN()</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35147#M8634</link>
      <description>hello SPR,&lt;BR /&gt;
&lt;BR /&gt;
thousand thanks for your reply &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
 I want to understand the code, so pls excuse me if I have some questions:&lt;BR /&gt;
&lt;BR /&gt;
1) now the final results are in r1-r&amp;amp;n =&amp;gt; I need them written back into table1, or did I misunderstand and due to the data r; set table1; =&amp;gt; all data is in table r?&lt;BR /&gt;
&lt;BR /&gt;
2) if             &amp;amp;&amp;amp;d&amp;amp;i &amp;lt;= 10 then r&amp;amp;i=1;&lt;BR /&gt;
=&amp;gt; isn't  &amp;amp;&amp;amp;d&amp;amp;i the macro variable from the SQL proc? if so, it contains the names of table2, not the values :(... somehow I need basic understanding of all the r&amp;amp;i and &amp;amp;&amp;amp;d&amp;amp;i... where can I read about the '&amp;amp;'? or is there any easy explanation of referencing and dereferencing (what I think is the mysterious &amp;amp;)&lt;BR /&gt;
&lt;BR /&gt;
thank you in advance.&lt;BR /&gt;
Tom</description>
      <pubDate>Tue, 16 Nov 2010 20:34:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35147#M8634</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-11-16T20:34:37Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with PUTVARN() and LOCATEN()</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35148#M8635</link>
      <description>OK, while working a bit with the code I think I start to understand&lt;BR /&gt;
&lt;BR /&gt;
in &amp;amp;d&amp;amp;i is the name of the variable, so &amp;amp; &amp;amp;d&amp;amp;i refers to the value of the name of the variable, right?&lt;BR /&gt;
&lt;BR /&gt;
if this is correct I will figure it out &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
Tom</description>
      <pubDate>Tue, 16 Nov 2010 21:00:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35148#M8635</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-11-16T21:00:31Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with PUTVARN() and LOCATEN()</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35149#M8636</link>
      <description>Hello Tom,&lt;BR /&gt;
&lt;BR /&gt;
1) If you need to rewrite simply replace r&amp;amp;i with d&amp;amp;i, e.g.&lt;BR /&gt;
[pre]&lt;BR /&gt;
replace 	  if             &amp;amp;&amp;amp;d&amp;amp;i &amp;lt;= 10 then r&amp;amp;i=1;&lt;BR /&gt;
with 		  if             &amp;amp;&amp;amp;d&amp;amp;i &amp;lt;= 10 then d&amp;amp;i=1;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
2) you are right.&lt;BR /&gt;
&lt;BR /&gt;
3) plase delete drop=i in my code. it is a leftover from the previous version.&lt;BR /&gt;
&lt;BR /&gt;
SPR</description>
      <pubDate>Tue, 16 Nov 2010 21:13:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35149#M8636</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2010-11-16T21:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with PUTVARN() and LOCATEN()</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35150#M8637</link>
      <description>Hello Tom,&lt;BR /&gt;
&lt;BR /&gt;
Sorry, the correct code for macro %a is like this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
%macro a;&lt;BR /&gt;
%local i;&lt;BR /&gt;
data r;&lt;BR /&gt;
  set table1;&lt;BR /&gt;
  %do i=1 %to &amp;amp;n;&lt;BR /&gt;
    /* Checking method */&lt;BR /&gt;
    if UPCASE("&amp;amp;&amp;amp;m&amp;amp;i") = "S%" then do;&lt;BR /&gt;
      if            &amp;amp;&amp;amp;d&amp;amp;i le 10 then &amp;amp;&amp;amp;d&amp;amp;i=1;&lt;BR /&gt;
      else if 10 lt &amp;amp;&amp;amp;d&amp;amp;i le 20 then &amp;amp;&amp;amp;d&amp;amp;i=2;&lt;BR /&gt;
      else if 20 lt &amp;amp;&amp;amp;d&amp;amp;i le 30 then &amp;amp;&amp;amp;d&amp;amp;i=3;&lt;BR /&gt;
      else if 30 lt &amp;amp;&amp;amp;d&amp;amp;i le 40 then &amp;amp;&amp;amp;d&amp;amp;i=4;&lt;BR /&gt;
      else if 40 lt &amp;amp;&amp;amp;d&amp;amp;i le 50 then &amp;amp;&amp;amp;d&amp;amp;i=5;&lt;BR /&gt;
      else if 50 lt &amp;amp;&amp;amp;d&amp;amp;i le 60 then &amp;amp;&amp;amp;d&amp;amp;i=6;&lt;BR /&gt;
      else if 60 lt &amp;amp;&amp;amp;d&amp;amp;i le 70 then &amp;amp;&amp;amp;d&amp;amp;i=7;&lt;BR /&gt;
      else if 60 lt &amp;amp;&amp;amp;d&amp;amp;i le 80 then &amp;amp;&amp;amp;d&amp;amp;i=8;&lt;BR /&gt;
      else if 80 lt &amp;amp;&amp;amp;d&amp;amp;i       then &amp;amp;&amp;amp;d&amp;amp;i=9;&lt;BR /&gt;
    end;&lt;BR /&gt;
  %end; &lt;BR /&gt;
run;&lt;BR /&gt;
%mend;&lt;BR /&gt;
%a&lt;BR /&gt;
[/pre]&lt;BR /&gt;
SPR</description>
      <pubDate>Tue, 16 Nov 2010 21:30:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35150#M8637</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2010-11-16T21:30:38Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with PUTVARN() and LOCATEN()</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35151#M8638</link>
      <description>first of all: I have never been closer &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; thx a lot...&lt;BR /&gt;
&lt;BR /&gt;
one thing left: I have put a control-print in the do-loop.. like this (btw... sorry I dont know how to post code in Courier font):&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
    if UPCASE("&amp;amp;&amp;amp;m&amp;amp;i") = "S%" then do;&lt;BR /&gt;
&lt;BR /&gt;
        %put changing &amp;amp;&amp;amp;d&amp;amp;i =&amp;gt; &amp;amp;&amp;amp;m&amp;amp;i;&lt;BR /&gt;
&lt;BR /&gt;
        if            &amp;amp;&amp;amp;d&amp;amp;i le 10 then &amp;amp;&amp;amp;d&amp;amp;i=1;&lt;BR /&gt;
        else if 10 lt &amp;amp;&amp;amp;d&amp;amp;i le 20 then &amp;amp;&amp;amp;d&amp;amp;i=2;&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
&lt;BR /&gt;
the result is the following:&lt;BR /&gt;
661        %a&lt;BR /&gt;
changing D_AUFG =&amp;gt; DATUM&lt;BR /&gt;
changing D_VEGB =&amp;gt; DATUM&lt;BR /&gt;
changing D_SCHN_3 =&amp;gt; DATUM&lt;BR /&gt;
changing D_SCHN_4 =&amp;gt; DATUM&lt;BR /&gt;
changing D_SCHN_5 =&amp;gt; DATUM&lt;BR /&gt;
changing D_SCHN_6 =&amp;gt; DATUM&lt;BR /&gt;
changing D_SCHN_7 =&amp;gt; DATUM&lt;BR /&gt;
changing D_SCHN_8 =&amp;gt; DATUM&lt;BR /&gt;
changing DICHVS_9 =&amp;gt; BON19&lt;BR /&gt;
changing DICHVS_10 =&amp;gt; BON19&lt;BR /&gt;
changing DICHVS_11 =&amp;gt; BON19&lt;BR /&gt;
changing DICHVS_12 =&amp;gt; BON19&lt;BR /&gt;
changing DICHVS_13 =&amp;gt; BON19&lt;BR /&gt;
changing DICHVS_14 =&amp;gt; BON19&lt;BR /&gt;
changing DICHVS_15 =&amp;gt; BON19&lt;BR /&gt;
changing DICHNS_16 =&amp;gt; BON19&lt;BR /&gt;
changing DICHNS_17 =&amp;gt; BON19&lt;BR /&gt;
changing DICHNS_18 =&amp;gt; BON19&lt;BR /&gt;
changing DICHNS_19 =&amp;gt; BON19&lt;BR /&gt;
changing DICHNS_20 =&amp;gt; BON19&lt;BR /&gt;
changing DICHNS_21 =&amp;gt; BON19&lt;BR /&gt;
changing DICHNS_22 =&amp;gt; BON19&lt;BR /&gt;
changing DICHVW =&amp;gt; BON19&lt;BR /&gt;
changing DICHNW =&amp;gt; BON19&lt;BR /&gt;
changing WDAVW_25 =&amp;gt; BON19&lt;BR /&gt;
changing WDANW_26 =&amp;gt; BON19&lt;BR /&gt;
changing WDAVS_27 =&amp;gt; BON19&lt;BR /&gt;
changing WDAVS_28 =&amp;gt; BON19&lt;BR /&gt;
changing WDAVS_29 =&amp;gt; BON19&lt;BR /&gt;
changing WDAVS_30 =&amp;gt; BON19&lt;BR /&gt;
&amp;#12;12                                         Das SAS System            23:07 Tuesday, November 16, 2010&lt;BR /&gt;
&lt;BR /&gt;
changing WDAVS_31 =&amp;gt; BON19&lt;BR /&gt;
changing WDAVS_32 =&amp;gt; BON19&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
&lt;BR /&gt;
am I wrong or does it change even values for DATUM and BON19??? (which it shouldnt do)?&lt;BR /&gt;
&lt;BR /&gt;
Tom</description>
      <pubDate>Tue, 16 Nov 2010 22:11:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35151#M8638</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-11-16T22:11:09Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with PUTVARN() and LOCATEN()</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35152#M8639</link>
      <description>hello SPR,&lt;BR /&gt;
&lt;BR /&gt;
but seems the %put statement is printed regardless of the result of the if-clause. I am such a newby... my god.&lt;BR /&gt;
&lt;BR /&gt;
I just added a counter that counts whenever the code enteres the if-clause, and the counter ended up by 18, which is a good value &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
thank you a lot for your precious time, you helped me a lot... &lt;BR /&gt;
and I still have to learn a lot about SAS... well after that project I will never have anything to do with SAS :)... well, never say never.&lt;BR /&gt;
&lt;BR /&gt;
so thank you again,&lt;BR /&gt;
Tom</description>
      <pubDate>Tue, 16 Nov 2010 22:27:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35152#M8639</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-11-16T22:27:18Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with PUTVARN() and LOCATEN()</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35153#M8640</link>
      <description>I may not understand competly but it sounds like all the information about what needs to be modified can be derived from "table2" the table of names and methods.&lt;BR /&gt;
&lt;BR /&gt;
From that you can create a data set of variables that need to be modified.  This data set can be used in a data step to create an array of the variables that need to be transformed.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc format;&lt;BR /&gt;
   value s2bon&lt;BR /&gt;
       0-&amp;lt;10 = '1'&lt;BR /&gt;
      10-&amp;lt;20 = '2'&lt;BR /&gt;
      20-&amp;lt;30 = '3'&lt;BR /&gt;
      30-&amp;lt;40 = '4'&lt;BR /&gt;
      40-&amp;lt;50 = '5'&lt;BR /&gt;
      50-&amp;lt;60 = '6'&lt;BR /&gt;
      60-&amp;lt;70 = '7'&lt;BR /&gt;
      70-&amp;lt;80 = '8'&lt;BR /&gt;
      80&amp;lt;-high='9'&lt;BR /&gt;
      ;&lt;BR /&gt;
   run;&lt;BR /&gt;
&lt;BR /&gt;
data density;&lt;BR /&gt;
   input year density1 density2 density10;&lt;BR /&gt;
   cards;&lt;BR /&gt;
2004 100 2 56&lt;BR /&gt;
2005 89 4 78&lt;BR /&gt;
2006 45 7 98&lt;BR /&gt;
;;;;&lt;BR /&gt;
   run;&lt;BR /&gt;
data method;   &lt;BR /&gt;
   input name:$32.  method:$8.;&lt;BR /&gt;
   retain i 0;&lt;BR /&gt;
   cards;&lt;BR /&gt;
density1 S%&lt;BR /&gt;
density2 BON19&lt;BR /&gt;
density10 S%&lt;BR /&gt;
;;;;&lt;BR /&gt;
   run;&lt;BR /&gt;
proc transpose data=method out=S(drop=_name_ where=(0));&lt;BR /&gt;
   where method eq 'S%';&lt;BR /&gt;
   id name;&lt;BR /&gt;
   var i;&lt;BR /&gt;
   run;&lt;BR /&gt;
proc contents varnum;&lt;BR /&gt;
   run;&lt;BR /&gt;
data density;&lt;BR /&gt;
   if 0 then set s;&lt;BR /&gt;
   array s&lt;LI&gt; _numeric_;&lt;BR /&gt;
   modify density;&lt;BR /&gt;
   do _n_ = 1 to dim(s);&lt;BR /&gt;
      s[_n_]=input(put(s[_n_],s2bon.),F1.);&lt;BR /&gt;
      end;&lt;BR /&gt;
   replace;&lt;BR /&gt;
   run;&lt;BR /&gt;
proc print data=density;&lt;BR /&gt;
   run;&lt;BR /&gt;
&lt;BR /&gt;
[/pre]&lt;/LI&gt;</description>
      <pubDate>Wed, 17 Nov 2010 12:13:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35153#M8640</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2010-11-17T12:13:49Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with PUTVARN() and LOCATEN()</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35154#M8641</link>
      <description>Hi&lt;BR /&gt;
&lt;BR /&gt;
It's always hard to post somthing after data _null_; .... but because I've already created the code I don't want to waste it now. So below what I planned to proprose:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
As always there are many ways in SAS to get a job done.&lt;BR /&gt;
&lt;BR /&gt;
Below a bit another approach which might work for you.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
/* --------------------- */&lt;BR /&gt;
/* 1. create sample data */&lt;BR /&gt;
data have;&lt;BR /&gt;
  input year density1 density2 densityX;&lt;BR /&gt;
  datalines;&lt;BR /&gt;
2004 100 2 56&lt;BR /&gt;
2005 89 4 78&lt;BR /&gt;
2006 45 7 98&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data Methods;&lt;BR /&gt;
  input name $ method $;&lt;BR /&gt;
  datalines;&lt;BR /&gt;
density1 S%&lt;BR /&gt;
density2 BON19&lt;BR /&gt;
densityX S%&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
/* -------------------- */&lt;BR /&gt;
/* 2. create format   */&lt;BR /&gt;
proc format;&lt;BR /&gt;
  value PctToMark&lt;BR /&gt;
    low -&amp;lt; 10   =1&lt;BR /&gt;
    10  -&amp;lt; 20   =2&lt;BR /&gt;
    20  -&amp;lt; 30   =3&lt;BR /&gt;
    30  -&amp;lt; 40   =4&lt;BR /&gt;
    40  -&amp;lt; 50   =5&lt;BR /&gt;
    50  -&amp;lt; 60   =6&lt;BR /&gt;
    60  -&amp;lt; 70   =7&lt;BR /&gt;
    70  -&amp;lt; 80   =8&lt;BR /&gt;
    80 - high    =9&lt;BR /&gt;
  ;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
/* ------------------------------------------------------------------*/&lt;BR /&gt;
/* 3. generate SAS data step code and write it to a temporary file   */&lt;BR /&gt;
filename tmpfile temp;&lt;BR /&gt;
data _null_;&lt;BR /&gt;
  file tmpfile;&lt;BR /&gt;
  set Methods;&lt;BR /&gt;
  if method='S%' then&lt;BR /&gt;
  do;&lt;BR /&gt;
    put name '=input(put(' name ',PctToMark.),8.);' ;&lt;BR /&gt;
  end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
/* ----------------------------------------------------------*/&lt;BR /&gt;
/* 4. convert % to marks using SAS code generated in step 3  */&lt;BR /&gt;
data want;&lt;BR /&gt;
  set have;&lt;BR /&gt;
  %include tmpfile;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc print data=want;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
The important thing in SAS:&lt;BR /&gt;
SAS executes a program from top to bottom and compiles and executes every run group (what ends with a "run") separately.&lt;BR /&gt;
&lt;BR /&gt;
That makes it possible in step 3 to use a data _null_ step (_null_: no SAS data set will be created) to generate SAS code (as text) and write this text to a temporary file.&lt;BR /&gt;
&lt;BR /&gt;
In step 4 this temporary file gets included (using a SAS macro language %include which is kind of pre-processing BEFORE the SAS language interpreter kicks in).&lt;BR /&gt;
The SAS interpreter therefore will "see" the SAS code which got written to the temporary file in step 3, compile the code in this run group and then execute.&lt;BR /&gt;
&lt;BR /&gt;
In step 2 a SAS format gets created. SAS formats and informats are used to write and read data (and are a fast way to convert data using kind of a lookup mechanism).&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Hope this explanations help. Others might have used more correct terminology (I'm always a bit at war with this).&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
HTH&lt;BR /&gt;
Patrick&lt;BR /&gt;
&lt;BR /&gt;
Message was edited by: Patrick</description>
      <pubDate>Wed, 17 Nov 2010 12:45:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problems-with-PUTVARN-and-LOCATEN/m-p/35154#M8641</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2010-11-17T12:45:51Z</dc:date>
    </item>
  </channel>
</rss>

