<?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: Data Step: Check if data is in column of CSV file in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Data-Step-Check-if-data-is-in-column-of-CSV-file/m-p/901878#M40238</link>
    <description>Sebastian,&lt;BR /&gt;You can't have an SQL step in the middle of a DATA step, and from the code shown I have no idea what the %LET statement was intended to accomplish. Please submit a few rows of the data sets you HAVE, and a few rows of what the desired result would look like.  Here is a link to an article that will help you share your existing data more easily:&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; &lt;BR /&gt;All the best,&lt;BR /&gt;Mark</description>
    <pubDate>Tue, 07 Nov 2023 13:06:41 GMT</pubDate>
    <dc:creator>SASJedi</dc:creator>
    <dc:date>2023-11-07T13:06:41Z</dc:date>
    <item>
      <title>Data Step: Check if data is in column of CSV file</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Data-Step-Check-if-data-is-in-column-of-CSV-file/m-p/901874#M40237</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have got a SAS .egp that does a evaluation of data for different cases and then puts this data in one Excel-file with 6 data sheets.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I have to change the program: so that in the data step where the cases are checked, should the program check if the ID is not in a CSV file (one column with the IDs only).&lt;/P&gt;&lt;P&gt;How can I do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have already this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc import datafile="temp.csv"
        out=temp
        dbms=csv
        replace;
    

     getnames=no;
run;

proc print data=work.temp;
run;&lt;/PRE&gt;&lt;P&gt;And now I want to check it with this code:&lt;/P&gt;&lt;PRE&gt;    data schritt2;&lt;BR /&gt;/* this is working correctly */
        set data_table; /* contains colums ARBEITSSTUNDENBEZAHLT, PERSONALNUMMER etc. */
        if ARBEITSSTUNDENBEZAHLT &amp;gt;400;

/* this is what I added: */
        %LET var=PERSONALNUMMER;
        
        proc sql;
		  select *
		  from WORK.TEMP 
		  where VAR1 = var; 
		
		  quit;
		  
/* how to do this? */
		if (ergebnis != TRUE); 

    run;&lt;/PRE&gt;&lt;P&gt;I hope someone could give me a hint.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Sebastian&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2023 12:32:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Data-Step-Check-if-data-is-in-column-of-CSV-file/m-p/901874#M40237</guid>
      <dc:creator>sgnd</dc:creator>
      <dc:date>2023-11-07T12:32:48Z</dc:date>
    </item>
    <item>
      <title>Re: Data Step: Check if data is in column of CSV file</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Data-Step-Check-if-data-is-in-column-of-CSV-file/m-p/901878#M40238</link>
      <description>Sebastian,&lt;BR /&gt;You can't have an SQL step in the middle of a DATA step, and from the code shown I have no idea what the %LET statement was intended to accomplish. Please submit a few rows of the data sets you HAVE, and a few rows of what the desired result would look like.  Here is a link to an article that will help you share your existing data more easily:&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; &lt;BR /&gt;All the best,&lt;BR /&gt;Mark</description>
      <pubDate>Tue, 07 Nov 2023 13:06:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Data-Step-Check-if-data-is-in-column-of-CSV-file/m-p/901878#M40238</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2023-11-07T13:06:41Z</dc:date>
    </item>
    <item>
      <title>Re: Data Step: Check if data is in column of CSV file</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Data-Step-Check-if-data-is-in-column-of-CSV-file/m-p/901990#M40251</link>
      <description>&lt;P&gt;Assuming you've got a base table and a lookup table for valid id's that both contain a variable ID then below code should work with minimal change.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data check;
  if _n_=1 then
    do;
      /* create and populate in-memory hash lookup table with valid id's */
      dcl hash h1(dataset:'work.valid_id');
      h1.defineKey('id');
      h1.defineDone();
    end;
  set work.base_table;
  /* below condition becomes TRUE if ID exists in hash lookup table */
  if h1.check()=0;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2023 23:14:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Data-Step-Check-if-data-is-in-column-of-CSV-file/m-p/901990#M40251</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-11-07T23:14:55Z</dc:date>
    </item>
  </channel>
</rss>

