<?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: Need help understanding this SQL code, a do loop and macro variable. in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Need-help-understanding-this-SQL-code-a-do-loop-and-macro/m-p/525926#M5031</link>
    <description>It may help to see what you did answer as well, to help gauge how much information we need to provide to you. All of those questions are what I would consider a SAS programmer with one year experience to be able to answer in some manner. I suspect some of the questions, #3 and #5, are actually designed to see how much you do know. &lt;BR /&gt;</description>
    <pubDate>Wed, 09 Jan 2019 22:34:52 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-01-09T22:34:52Z</dc:date>
    <item>
      <title>Need help understanding this SQL code, a do loop and macro variable.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-help-understanding-this-SQL-code-a-do-loop-and-macro/m-p/525915#M5029</link>
      <description>&lt;P&gt;Hello all. I am a novice SAS user, mostly base, though have used and slightly manipulated programs using proc sql, macros etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I recently faced some tough (from my perspective) questions in an interview for a position that uses SAS. I am asking from memory, but was hoping someone could take the time to explain in slight detail some of the answers (or HOW i should have answered here).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) Look at this sample code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;sql&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;create table C as&lt;/P&gt;&lt;P&gt;select A.VA, B.VB,&lt;/P&gt;&lt;P&gt;from A left join B&lt;/P&gt;&lt;P&gt;on strip(A.VA) = strip(B.VA)&lt;/P&gt;&lt;P&gt;order by VA;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Quit&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please describe what this does and the exact detail of the output dataset C&amp;nbsp; (Variables and observations)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2)&amp;nbsp;How do you use the do loop if you don’t know how many times you should execute the do loop?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3)&amp;nbsp;How many ways to create a format using Proc Format?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;4) Can you explain the differences between a macro program and a macro variable?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;5)&amp;nbsp;How many ways are there to create a macro variable?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I feel like I must have done very poorly on these, and rather than spend more time researching in looking it up I am asking for some help as a relatively novice user. Any help appreciated. Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cristoban&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jan 2019 22:14:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-help-understanding-this-SQL-code-a-do-loop-and-macro/m-p/525915#M5029</guid>
      <dc:creator>cristoban</dc:creator>
      <dc:date>2019-01-09T22:14:50Z</dc:date>
    </item>
    <item>
      <title>Re: Need help understanding this SQL code, a do loop and macro variable.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-help-understanding-this-SQL-code-a-do-loop-and-macro/m-p/525926#M5031</link>
      <description>It may help to see what you did answer as well, to help gauge how much information we need to provide to you. All of those questions are what I would consider a SAS programmer with one year experience to be able to answer in some manner. I suspect some of the questions, #3 and #5, are actually designed to see how much you do know. &lt;BR /&gt;</description>
      <pubDate>Wed, 09 Jan 2019 22:34:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-help-understanding-this-SQL-code-a-do-loop-and-macro/m-p/525926#M5031</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-01-09T22:34:52Z</dc:date>
    </item>
    <item>
      <title>Re: Need help understanding this SQL code, a do loop and macro variable.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-help-understanding-this-SQL-code-a-do-loop-and-macro/m-p/525956#M5036</link>
      <description>&lt;P&gt;Most of the answers to these questions would be relatively useless to you.&amp;nbsp; The next interview you go on could easily ask very different questions, on very different topics.&amp;nbsp; If you need to learn SAS, learn SAS.&amp;nbsp; That would take an exceedingly long time if you do it by asking questions based on interview questions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The one question from the interview that would be useful would be the first one.&amp;nbsp; Knowing the basics of PROC SQL would be useful.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here are a few more topics you can research and study.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What happens when you add a BY statement to a DATA step?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When combining SAS data sets, how do you find matches and mismatches?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do you get an output data set from PROC MEANS?&amp;nbsp; What is the effect of a CLASS statement?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How does SAS test whether A &amp;gt; B, when A and B are character variables?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are many more topics I could add to the list.&amp;nbsp; But this is as good a starting point as any.&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2019 01:50:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-help-understanding-this-SQL-code-a-do-loop-and-macro/m-p/525956#M5036</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-01-10T01:50:14Z</dc:date>
    </item>
    <item>
      <title>Re: Need help understanding this SQL code, a do loop and macro variable.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-help-understanding-this-SQL-code-a-do-loop-and-macro/m-p/526942#M5178</link>
      <description>&lt;P&gt;Well for the first one, the proc sql code, which is the one I am most concerned with, I had said it created a new dataset&amp;nbsp; taking variables A and B from datasets (or tables as referred to sql) and in the new dataset C, its left join which takes everything from A, even if there is nothing from B.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where my confusion came is the on strip clause. I mentioned strip removing leading/trailing zeros blanks, so by guess was that it would produce a dataset where there was matches anywhere in dataset A and B regardless of blanks or zeros. But I am, not sure this is correct&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jan 2019 14:34:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-help-understanding-this-SQL-code-a-do-loop-and-macro/m-p/526942#M5178</guid>
      <dc:creator>cristoban</dc:creator>
      <dc:date>2019-01-14T14:34:15Z</dc:date>
    </item>
    <item>
      <title>Re: Need help understanding this SQL code, a do loop and macro variable.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-help-understanding-this-SQL-code-a-do-loop-and-macro/m-p/526946#M5179</link>
      <description>&lt;P&gt;Since SAS stores character variables as fixed length it already ignores trailing blanks in comparisons.&amp;nbsp; So 'AB&amp;nbsp; &amp;nbsp; &amp;nbsp;' is equal to 'AB'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Adding the STRIP() function call means that you want the test to also ignore any leading blanks.&amp;nbsp; So '&amp;nbsp; &amp;nbsp; AB&amp;nbsp; &amp;nbsp; ' is equal to 'AB'.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jan 2019 14:49:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-help-understanding-this-SQL-code-a-do-loop-and-macro/m-p/526946#M5179</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-01-14T14:49:46Z</dc:date>
    </item>
    <item>
      <title>Re: Need help understanding this SQL code, a do loop and macro variable.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-help-understanding-this-SQL-code-a-do-loop-and-macro/m-p/526980#M5183</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/254329"&gt;@cristoban&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Well for the first one, the proc sql code, which is the one I am most concerned with, I had said it created a new dataset&amp;nbsp; taking variables A and B from datasets&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It's taking variables VA and VB, the A and B are table alias to indicate which is the source table, so that is incorrect.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/254329"&gt;@cristoban&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;its left join which takes everything from A, even if there is nothing from B.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This part is mostly correct, any records with an ID in A is kept, so your output data set size should be &amp;gt;= size of data set A, assuming no WHERE statements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;P&gt;Where my confusion came is the on strip clause. I mentioned&lt;STRONG&gt; strip removing leading/trailing zeros blanks&lt;/STRONG&gt;, so by guess was that it would produce a dataset where there was matches anywhere in dataset A and B regardless of blanks or zeros. But I am, not sure this is correct&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;&amp;nbsp;STRIP() only affects leading spaces, not zeroes, so that portion is incorrect.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jan 2019 16:40:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-help-understanding-this-SQL-code-a-do-loop-and-macro/m-p/526980#M5183</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-01-14T16:40:04Z</dc:date>
    </item>
  </channel>
</rss>

