<?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 to read arguments of a function from a dataset? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-read-arguments-of-a-function-from-a-dataset/m-p/164813#M42731</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data lookup; &lt;BR /&gt;&amp;nbsp; length name $20;&lt;BR /&gt;&amp;nbsp; input name;&lt;BR /&gt;cards;&lt;BR /&gt;George&lt;BR /&gt;Harry&lt;BR /&gt;John&lt;BR /&gt;Sam&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have; &lt;BR /&gt; input line1 $80.;&lt;BR /&gt;cards;&lt;BR /&gt;Some text that contains George&lt;BR /&gt;Some text that contains Harry&lt;BR /&gt;None of the names&lt;BR /&gt;Two of the names George, and JOHN.&lt;BR /&gt;Some text that contains nothing&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table have as&lt;BR /&gt;select * from lookup,have&lt;BR /&gt;order by name;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want(keep=name CountG);&lt;BR /&gt;set have;&lt;BR /&gt;by name;&lt;BR /&gt;if first.name then CountG=0;&lt;BR /&gt;if index(upcase(line1),upcase(strip(name)))&amp;gt;0 then CountG+1;&lt;BR /&gt;if last.name;&lt;BR /&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 03 Jul 2014 17:39:33 GMT</pubDate>
    <dc:creator>stat_sas</dc:creator>
    <dc:date>2014-07-03T17:39:33Z</dc:date>
    <item>
      <title>How to read arguments of a function from a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-read-arguments-of-a-function-from-a-dataset/m-p/164809#M42727</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello All;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to search some names in a url. I am using the index function to find the word, for example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if index(line1,'GEORGE') ne 0 then do;&lt;/P&gt;&lt;P&gt;countG = countG + 1 ;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My problem is that, I want to choose the names from a list. So, I want SAS to read the first name from a local data set, put it as the argument in the index function and search for it, and then goes for the second name from the list, and so on. The list is huge so I cannot list them manually.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not very knowledgeable in SAS, so I would be grateful if help me how to write this part.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Jul 2014 00:50:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-read-arguments-of-a-function-from-a-dataset/m-p/164809#M42727</guid>
      <dc:creator>Shayan2012</dc:creator>
      <dc:date>2014-07-03T00:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to read arguments of a function from a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-read-arguments-of-a-function-from-a-dataset/m-p/164810#M42728</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this and see if it meets some of your requirements:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data lookup; * this is your list with names;&lt;/P&gt;&lt;P&gt;length name $20;&lt;/P&gt;&lt;P&gt;input name;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;George&lt;/P&gt;&lt;P&gt;Harry&lt;/P&gt;&lt;P&gt;John&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have; * this is the dataset having the field you want to explore;&lt;/P&gt;&lt;P&gt;infile cards truncover;&lt;/P&gt;&lt;P&gt;input line1 $100.;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;Some text that contains George&lt;/P&gt;&lt;P&gt;Some text that contains Harry&lt;/P&gt;&lt;P&gt;Some text that contains nothing&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_; * build a piece of code dynamically;&lt;/P&gt;&lt;P&gt;set lookup end=last;&lt;/P&gt;&lt;P&gt;length commandstring $100;&lt;/P&gt;&lt;P&gt;if _N_ = 1 then call execute("data want;set have;");&lt;/P&gt;&lt;P&gt;commandstring = "if index(line1,'"!!strip(name)!!"') ne 0 then count_"!!strip(name)!!" = sum(count_"!!strip(name)!!",1);";&lt;/P&gt;&lt;P&gt;call execute(commandstring);&lt;/P&gt;&lt;P&gt;if last then call execute("run;");&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Jul 2014 09:12:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-read-arguments-of-a-function-from-a-dataset/m-p/164810#M42728</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2014-07-03T09:12:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to read arguments of a function from a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-read-arguments-of-a-function-from-a-dataset/m-p/164811#M42729</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin-bottom: .0001pt; background: white;"&gt;&lt;SPAN style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt;Hi Shayan2012,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-size: 10pt; font-family: Helvetica, sans-serif;"&gt;Welcome to SAS.&amp;nbsp; As you are new to SAS I have broken down how the code works within the comments, however if there is something you don't understand please let me know.&amp;nbsp; Loading a dataset into a hash object is limited by the amount of memory you have available.&amp;nbsp; You haven't mentioned in your post exactly how large the list is, so run the below code and see how you progress.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*SET UP TEST DATA*/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA HAVE;&lt;/P&gt;&lt;P&gt;LENGTH LINE1 $200;&lt;/P&gt;&lt;P&gt;INFILE DATALINES;&lt;/P&gt;&lt;P&gt;INPUT LINE1 $;&lt;/P&gt;&lt;P&gt;DATALINES;&lt;/P&gt;&lt;P&gt;HHHHHHHHHHHHGEORGEGARRY&lt;/P&gt;&lt;P&gt;5646546465HARRYGARRYBARRY&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*SET UP LIST OF VALUES WE WISH TO LOOK FOR*/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA LIST;&lt;/P&gt;&lt;P&gt;LENGTH NAMESLIST $7;&lt;/P&gt;&lt;P&gt;NAMESLIST = "HARRY";&lt;/P&gt;&lt;P&gt;OUTPUT;&lt;/P&gt;&lt;P&gt;NAMESLIST = "BARRY";&lt;/P&gt;&lt;P&gt;OUTPUT;&lt;/P&gt;&lt;P&gt;NAMESLIST = "GEORGE";&lt;/P&gt;&lt;P&gt;OUTPUT;&lt;/P&gt;&lt;P&gt;NAMESLIST = "GARRY";&lt;/P&gt;&lt;P&gt;OUTPUT;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA LOOKUP;&lt;/P&gt;&lt;P&gt;/*LOAD LIST DATASET INTO A HASH TABLE AND DECLARE THE ITERATOR*/&lt;/P&gt;&lt;P&gt;IF _N_ = 1 THEN DO;&lt;/P&gt;&lt;P&gt;LENGTH NAMESLIST $6;&lt;/P&gt;&lt;P&gt;DECLARE HASH HA(DATASET:"LIST");&lt;/P&gt;&lt;P&gt;DECLARE HITER HI("HA");&lt;/P&gt;&lt;P&gt;HA.DEFINEKEY("NAMESLIST");&lt;/P&gt;&lt;P&gt;HA.DEFINEDATA("NAMESLIST");&lt;/P&gt;&lt;P&gt;HA.DEFINEDONE();&lt;/P&gt;&lt;P&gt;CALL MISSING(NAMESLIST);&lt;/P&gt;&lt;P&gt;END;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*READ IN HAVE DATASET AS NORMAL*/&lt;/P&gt;&lt;P&gt;SET HAVE;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*READ IN THE FIRST RECORD IN HASH TABLE*/&lt;/P&gt;&lt;P&gt;RC = HI.FIRST();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*CREATE AN ARRAY CALLED _COUNT CONTAIN VARIABLES COUNTA TO COUNTZ*/&lt;/P&gt;&lt;P&gt;ARRAY _COUNT {*} COUNTA COUNTB COUNTC COUNTD COUNTE COUNTF COUNTG COUNTH COUNTI&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; COUNTJ COUNTK COUNTL COUNTM COUNTN COUNTO COUNTP COUNTQ COUNTR&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; COUNTS COUNTT COUNTU COUNTV COUNTW COUNTX COUNTY COUNTZ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL MISSING(COUNTA,COUNTB,COUNTC,COUNTD,COUNTE,COUNTF,COUNTG,COUNTH,COUNTI,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; COUNTJ,COUNTK,COUNTL,COUNTM,COUNTN,COUNTO,COUNTP,COUNTQ,COUNTR,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; COUNTS,COUNTT,COUNTU,COUNTV,COUNTW,COUNTX,COUNTY,COUNTZ);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DO WHILE (RC = 0);&lt;/P&gt;&lt;P&gt;&amp;nbsp; /*IF THE NAME IN THE HASH TABLE RECORD APPEARS IN THE STRING FROM THE HAVE DATASET THEN*/&lt;/P&gt;&lt;P&gt;&amp;nbsp; IF INDEX(LINE1,TRIM(NAMESLIST)) ~= 0 THEN DO;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /*SET NUMBER OF ITERATIONS REQUIRED TO MOVE THROUGH ALL VARIABLES WITHIN THE ARRAY*/&lt;/P&gt;&lt;P&gt;&amp;nbsp; DO I = 1 TO 26;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /*IF THE LAST VALUE IN THE VARIABLE ARRAY APPEARS AS THE FIRST CHARACTER OF THE VALUE IN THE NAMELIST VARIABLE THEN */&lt;/P&gt;&lt;P&gt;&amp;nbsp; IF TRIM(SUBSTR(VNAME(_COUNT{I}),6,1)) = TRIM(SUBSTR(NAMESLIST,1,1)) THEN DO;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /*ADD 1 TO THE RELEVANT ARRAY ELEMENT*/&lt;/P&gt;&lt;P&gt;&amp;nbsp; _COUNT{I} = SUM(_COUNT{I},1);&lt;/P&gt;&lt;P&gt;&amp;nbsp; /*ONCE THE NAME IS FOUND THEN LEAVE THE DO LOOP*/&lt;/P&gt;&lt;P&gt;LEAVE;&lt;/P&gt;&lt;P&gt;&amp;nbsp; END;&lt;/P&gt;&lt;P&gt;&amp;nbsp; END;&lt;/P&gt;&lt;P&gt;&amp;nbsp; END;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /*READ IN THE NEXT RECORD FROM THE HASH TABLE*/&lt;/P&gt;&lt;P&gt;&amp;nbsp; RC = HI.NEXT();&lt;/P&gt;&lt;P&gt;END;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DROP I;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Jul 2014 10:09:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-read-arguments-of-a-function-from-a-dataset/m-p/164811#M42729</guid>
      <dc:creator>Scott_Mitchell</dc:creator>
      <dc:date>2014-07-03T10:09:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to read arguments of a function from a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-read-arguments-of-a-function-from-a-dataset/m-p/164812#M42730</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You might be able to use PROC SQL to do this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: green; background: white;"&gt;* this is your list with names;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; lookup; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;length&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; name $&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;20&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; name;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;cards&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;George&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;Harry&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;John&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;Sam&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: green; background: white;"&gt;* this is the dataset having the field you want to explore;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; have; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; line1 &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: teal; background: white;"&gt;$80.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;cards&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;Some text that contains George&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;Some text that contains Harry&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;None of the names&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;Two of the names George, and JOHN.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;Some text that contains nothing&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;sql&lt;/STRONG&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;noprint&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;create&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;table&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; want &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; a.name,count(line1) &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; count&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; lookup a &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;left&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;join&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; have b&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;on&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;index&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;(upcase(b.line1),upcase(trim(a.name)))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;group&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;by&lt;/SPAN&gt; &lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;order&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;by&lt;/SPAN&gt; &lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Jul 2014 14:23:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-read-arguments-of-a-function-from-a-dataset/m-p/164812#M42730</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-07-03T14:23:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to read arguments of a function from a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-read-arguments-of-a-function-from-a-dataset/m-p/164813#M42731</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data lookup; &lt;BR /&gt;&amp;nbsp; length name $20;&lt;BR /&gt;&amp;nbsp; input name;&lt;BR /&gt;cards;&lt;BR /&gt;George&lt;BR /&gt;Harry&lt;BR /&gt;John&lt;BR /&gt;Sam&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have; &lt;BR /&gt; input line1 $80.;&lt;BR /&gt;cards;&lt;BR /&gt;Some text that contains George&lt;BR /&gt;Some text that contains Harry&lt;BR /&gt;None of the names&lt;BR /&gt;Two of the names George, and JOHN.&lt;BR /&gt;Some text that contains nothing&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table have as&lt;BR /&gt;select * from lookup,have&lt;BR /&gt;order by name;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want(keep=name CountG);&lt;BR /&gt;set have;&lt;BR /&gt;by name;&lt;BR /&gt;if first.name then CountG=0;&lt;BR /&gt;if index(upcase(line1),upcase(strip(name)))&amp;gt;0 then CountG+1;&lt;BR /&gt;if last.name;&lt;BR /&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Jul 2014 17:39:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-read-arguments-of-a-function-from-a-dataset/m-p/164813#M42731</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-07-03T17:39:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to read arguments of a function from a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-read-arguments-of-a-function-from-a-dataset/m-p/164814#M42732</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot, Scott_Mitchell!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I learnt many new things from your code, but I am not sure if I fully understood how it works in some parts.&lt;/P&gt;&lt;P&gt;As far as I figured, you first construct a hash table of names from the list dataset, and then match these names in the line1 varibale from have dataset. However, I am not sure what is the purpose of the " DO WHILE" loop that comes afterwards, and I am not sure what is this condition testing for:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;&amp;nbsp; IF TRIM(SUBSTR(VNAME(_COUNT{I}),6,1)) = TRIM(SUBSTR(NAMESLIST,1,1)) THEN DO;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;And, finally, I ran the exact code, and this is the final table that I am getting:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;( I have omitted the other COUNT ARRAYS which are all missing)&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid rgb(0, 0, 0); width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;NAMESLIST&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;LINE1&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;RC&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;countB&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;countG&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;countH&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;&lt;P&gt;GARRY&lt;/P&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;HHHHHHHHHHHHGEORGEGARRY&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;160038&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;.&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;GARRY&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;5646546465HARRYGARRYBARRY&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;160038&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;So, can you please desribe what does this RC and these counters are telling me? and why we can not see GEORGE in the nameslist? &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;Thank you so so much,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;shayan&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Jul 2014 21:17:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-read-arguments-of-a-function-from-a-dataset/m-p/164814#M42732</guid>
      <dc:creator>Shayan2012</dc:creator>
      <dc:date>2014-07-03T21:17:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to read arguments of a function from a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-read-arguments-of-a-function-from-a-dataset/m-p/164815#M42733</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much Tom, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think I understand your code, but one thing that I am trying to do is to extract the line that actually contains the name. So, is it a way to modify the code such that the WANT table also includes the line that the name e.g. GEORGE was find in?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Jul 2014 21:34:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-read-arguments-of-a-function-from-a-dataset/m-p/164815#M42733</guid>
      <dc:creator>Shayan2012</dc:creator>
      <dc:date>2014-07-03T21:34:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to read arguments of a function from a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-read-arguments-of-a-function-from-a-dataset/m-p/164816#M42734</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;I thought the point was to count them?&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff;"&gt;&lt;SPAN style="color: #000000; font-family: 'Courier New';"&gt;&lt;SPAN style="font-style: inherit; font-weight: inherit;"&gt;SAS has a nice &lt;/SPAN&gt;extension&lt;SPAN style="font-style: inherit; font-weight: inherit;"&gt; to normal SQL syntax in that it allows you to keep both the aggregate functions like COUNT() and the detail rows. It will happily populate all of the rows for the group with the COUNT() for that group.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'Courier New'; color: black;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;STRONG style="font-style: inherit; font-family: 'Courier New'; color: navy;"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="font-style: inherit; font-family: 'Courier New'; color: navy;"&gt;sql&lt;/STRONG&gt; &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'Courier New'; color: blue;"&gt;noprint&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'Courier New'; color: black;"&gt; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'Courier New'; color: blue;"&gt;create&lt;/SPAN&gt; &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'Courier New'; color: blue;"&gt;table&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'Courier New'; color: black;"&gt; want &lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'Courier New'; color: blue;"&gt;as&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'Courier New'; color: blue;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'Courier New'; color: black;"&gt; a.name,count(b.line1) &lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'Courier New'; color: blue;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'Courier New'; color: black;"&gt; count, b.line1&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'Courier New'; color: blue;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'Courier New'; color: black;"&gt; lookup a &lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'Courier New'; color: blue;"&gt;left&lt;/SPAN&gt; &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'Courier New'; color: blue;"&gt;join&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'Courier New'; color: black;"&gt; have b&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'Courier New'; color: blue;"&gt;on&lt;/SPAN&gt; &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'Courier New'; color: blue;"&gt;index&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'Courier New'; color: black;"&gt;(upcase(b.line1),upcase(trim(a.name)))&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'Courier New'; color: blue;"&gt;group&lt;/SPAN&gt; &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'Courier New'; color: blue;"&gt;by&lt;/SPAN&gt; &lt;STRONG style="font-style: inherit; font-family: 'Courier New'; color: teal;"&gt;1&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'Courier New'; color: blue;"&gt;order&lt;/SPAN&gt; &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'Courier New'; color: blue;"&gt;by&lt;/SPAN&gt; &lt;STRONG style="font-style: inherit; font-family: 'Courier New'; color: teal;"&gt;1&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;STRONG style="font-style: inherit; font-family: 'Courier New'; color: navy;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'Courier New'; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'Courier New'; color: black;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Normally with SQL queries you have to remerge the counts yourself. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Jul 2014 22:09:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-read-arguments-of-a-function-from-a-dataset/m-p/164816#M42734</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-07-03T22:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to read arguments of a function from a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-read-arguments-of-a-function-from-a-dataset/m-p/164817#M42735</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Shayan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am more than happy to explain the code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let's look at the DO WHILE loop first:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You are right that we are loading the dataset NAMESLIST into a hash table, the lookup key being NAMESLIST also, because that is what I named the the variable &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;(&lt;/SPAN&gt;probably a little confusing for a new user in hindsight).&amp;nbsp; We also declare a hash iterator which allows us to iterate through the values contained within the hash table.&amp;nbsp; This is why we have the do while loop and the RC record control variables. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HI.FIRST&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;(&lt;/SPAN&gt;) moves the iterator to the top of the hash table, we do this for each record read in by the SET HAVE statement.&amp;nbsp; If it is successful in doing so then RC = 0 else RC not = 0.&amp;nbsp; If RC = 0 then the do loop will process the code for the first time with NAMESLIST containing the first value in the hash table throughout eventually reaching RC = HI.NEXT().&amp;nbsp; RC = HI.NEXT() tells the iterator to read in the next record.&amp;nbsp; If successful RC = 0 else RC not = 0.&amp;nbsp; If RC = 0 the next record is read in and the do loop is processed again. If RC not = 0 then the end of the hash table has been reached then exit the do loop as DO WHILE (RC = 0) is false.&amp;nbsp; The next record from HAVE is read in and we go through the above process again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Now let's explore the IF TRIM(SUBSTR(VNAME(_COUNT{I}),6,1)) = TRIM(SUBSTR(NAMESLIST,1,1)) THEN DO syntax.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;_COUNT is the name of the ARRAY created earlier in the code by the ARRAY statement.&amp;nbsp; &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;_COUNT{I} means go to element I &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;(which is the value from the created by the DO I = 1 TO 26 loop&lt;/SPAN&gt;).&amp;nbsp; Typically we would want the value contained within&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;_COUNT{I}, however by using the &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;VNAME function we obtain the variable name associated with the relevant iteration of &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 10pt; line-height: 1.5em; background-color: #ffffff;"&gt;_COUNT{I}.&amp;nbsp; So if I = 1 then &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;VNAME&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;(&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;_COUNT{I}) = COUNTA, if &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;I = 2 then &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;VNAME&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;(&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;_COUNT{I}) = COUNTB and so on. We then use SUBSTR to extract the last character of the variable name and TRIM the result to remove any trailing blanks.&amp;nbsp; &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;TRIM(SUBSTR(NAMESLIST,1,1)) simply obtains the first character from the NAMESLIST variable from the current iteration through the hash table and trims the result. If the two values are equal then we add 1 to the count of that variable.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;To answer you question regarding why you can't see GEORGE in NAMELIST.&amp;nbsp; Every time you iterate through the values in hash table the value in NAMESLIST is overwritten.&amp;nbsp; You can see that both GEORGE and GARRY have been located in the first OBS of the HAVE table because COUNTG = 2.&amp;nbsp; If you don't believe me that GEORGE is being evaluated simply add PUT _N_= NAMESLIST=; immediately after DO WHILE (RC = 0); and you will see what NAMESLIST contained for each record of HAVE in the log. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;I hope that this helps you better understand my code.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Jul 2014 03:52:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-read-arguments-of-a-function-from-a-dataset/m-p/164817#M42735</guid>
      <dc:creator>Scott_Mitchell</dc:creator>
      <dc:date>2014-07-04T03:52:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to read arguments of a function from a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-read-arguments-of-a-function-from-a-dataset/m-p/164818#M42736</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much for the comprehensive description, Scott_mitchell. You're awesome!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jul 2014 15:31:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-read-arguments-of-a-function-from-a-dataset/m-p/164818#M42736</guid>
      <dc:creator>Shayan2012</dc:creator>
      <dc:date>2014-07-08T15:31:24Z</dc:date>
    </item>
  </channel>
</rss>

