<?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 access the link in an external look up table? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-access-the-link-in-an-external-look-up-table/m-p/16410#M2277</link>
    <description>This will involve FILENAME statements and FILENAME functions, and may require use of FETCH or FETCHOBS, or not.&lt;BR /&gt;
&lt;BR /&gt;
You may want to look into CALL EXECUTE and look into some macro programming.&lt;BR /&gt;
&lt;BR /&gt;
An easier way may be to use PROC SQL and simply use some will constructed joins.&lt;BR /&gt;
&lt;BR /&gt;
It all depends on how you want to apply the range checking.</description>
    <pubDate>Thu, 08 May 2008 14:47:18 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-05-08T14:47:18Z</dc:date>
    <item>
      <title>How to access the link in an external look up table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-access-the-link-in-an-external-look-up-table/m-p/16409#M2276</link>
      <description>I want to range check a dataset and have an external lookup table containing variable names and links to where their valid values are stored. &lt;BR /&gt;
&lt;BR /&gt;
errorvar   lookupfile&lt;BR /&gt;
state      /c:/myfile/state.csv&lt;BR /&gt;
gender   /c:/myfle/gender.csv&lt;BR /&gt;
...&lt;BR /&gt;
&lt;BR /&gt;
I want to retrieve the valid values stored in those lookup files and compare those values with my data. I want to create an indicator which equals "yes" when there is a match and "no" when there is no match. &lt;BR /&gt;
&lt;BR /&gt;
Can anybody help me find a solution? Thanks a million.</description>
      <pubDate>Thu, 08 May 2008 12:59:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-access-the-link-in-an-external-look-up-table/m-p/16409#M2276</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-05-08T12:59:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to access the link in an external look up table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-access-the-link-in-an-external-look-up-table/m-p/16410#M2277</link>
      <description>This will involve FILENAME statements and FILENAME functions, and may require use of FETCH or FETCHOBS, or not.&lt;BR /&gt;
&lt;BR /&gt;
You may want to look into CALL EXECUTE and look into some macro programming.&lt;BR /&gt;
&lt;BR /&gt;
An easier way may be to use PROC SQL and simply use some will constructed joins.&lt;BR /&gt;
&lt;BR /&gt;
It all depends on how you want to apply the range checking.</description>
      <pubDate>Thu, 08 May 2008 14:47:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-access-the-link-in-an-external-look-up-table/m-p/16410#M2277</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-05-08T14:47:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to access the link in an external look up table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-access-the-link-in-an-external-look-up-table/m-p/16411#M2278</link>
      <description>Hi:&lt;BR /&gt;
Depending on how often the values in the CSV files change, you may be able to use the features of PROC FORMAT to create a user-defined format from your CSV files...&lt;BR /&gt;
&lt;BR /&gt;
1) read the CSV file into SAS&lt;BR /&gt;
2) create a dataset tailored to PROC FORMAT CNTLIN&lt;BR /&gt;
3) run a PROC FORMAT step using the dataset in #2&lt;BR /&gt;
4) then the new format is available for doing the kind of recoding you want -- you can build the format on a permanent basis if the data doesn't change much or you can build the format each time you run the job that does the validation checking. &lt;BR /&gt;
5) repeat #1, 2 and 3 for every one of your variables -- probably in a SAS Macro program -- as Chuck indicated.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
There's an example at the end of this post that uses SASHELP.SHOES as an  example...to create 1 format for Product and create a new variable with the format.&lt;BR /&gt;
&lt;BR /&gt;
If your data changes hourly or daily, this might not be the preferred approach. but if your CSV files only change weekly or occasionally, then you might be able to work a CNTLIN/PROC FORMAT example into a SAS Macro program solution that would update the permanent formats when the CSV files changed. OR you could set up a periodic refresh.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
                    &lt;BR /&gt;
** make some data to test;&lt;BR /&gt;
** You would read your CSV file here;&lt;BR /&gt;
** Only Products listed here will be coded with 'Yes';&lt;BR /&gt;
data file1;&lt;BR /&gt;
  length Product $14;&lt;BR /&gt;
  infile datalines dlm=',' dsd;&lt;BR /&gt;
  input Product $ ;&lt;BR /&gt;
return;&lt;BR /&gt;
datalines;&lt;BR /&gt;
"Boot" &lt;BR /&gt;
"Men's Casual" &lt;BR /&gt;
"Men's Dress" &lt;BR /&gt;
"Women's Casual" &lt;BR /&gt;
"Women's Dress" &lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
                 &lt;BR /&gt;
ods listing;&lt;BR /&gt;
                              &lt;BR /&gt;
** make a user-defined format for the products;&lt;BR /&gt;
Data fmt_from_data;&lt;BR /&gt;
  set work.file1(rename=(product=start)) end=eof;&lt;BR /&gt;
  Retain FMTNAME "PRODF"&lt;BR /&gt;
         TYPE    "C";&lt;BR /&gt;
  Length LABEL $60;&lt;BR /&gt;
  Label = "Yes";&lt;BR /&gt;
  output;&lt;BR /&gt;
  if eof then do;&lt;BR /&gt;
      hlo="O";&lt;BR /&gt;
      label="No";&lt;BR /&gt;
      output;&lt;BR /&gt;
   end;&lt;BR /&gt;
Run;&lt;BR /&gt;
                          &lt;BR /&gt;
Proc Format CntlIn = fmt_from_data fmtlib;&lt;BR /&gt;
Run;&lt;BR /&gt;
                     &lt;BR /&gt;
** start ODS;&lt;BR /&gt;
ods listing close;&lt;BR /&gt;
ods html file='c:\temp\useFmt.html' style=sasweb;&lt;BR /&gt;
                 &lt;BR /&gt;
data makeflag;&lt;BR /&gt;
  set sashelp.shoes;&lt;BR /&gt;
  newflag = put(product,$PRODF.);&lt;BR /&gt;
run;&lt;BR /&gt;
             &lt;BR /&gt;
proc print data=makeflag;&lt;BR /&gt;
where region = 'Asia';&lt;BR /&gt;
var region product newflag sales;&lt;BR /&gt;
title 'Only Print One Region';&lt;BR /&gt;
run;&lt;BR /&gt;
                 &lt;BR /&gt;
** PROC FREQ;&lt;BR /&gt;
proc freq data=makeflag;&lt;BR /&gt;
  title 'Using Format to Double Check Values for Product';&lt;BR /&gt;
  tables product newflag;&lt;BR /&gt;
  format product $PRODF.;&lt;BR /&gt;
run;&lt;BR /&gt;
                        &lt;BR /&gt;
title;&lt;BR /&gt;
ods html close;&lt;BR /&gt;
  &lt;BR /&gt;
[/pre]</description>
      <pubDate>Thu, 08 May 2008 15:52:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-access-the-link-in-an-external-look-up-table/m-p/16411#M2278</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2008-05-08T15:52:45Z</dc:date>
    </item>
  </channel>
</rss>

