<?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: Proc Print Example: Select all observations (rows) where the Name column has length 1 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-Print-Example-Select-all-observations-rows-where-the-Name/m-p/743858#M232980</link>
    <description>The variable of interest is NAME.&lt;BR /&gt;&lt;BR /&gt;This solution is what I intuitively wanted to do. Thanks.</description>
    <pubDate>Wed, 26 May 2021 13:09:51 GMT</pubDate>
    <dc:creator>SasStatistics</dc:creator>
    <dc:date>2021-05-26T13:09:51Z</dc:date>
    <item>
      <title>Proc Print Example: Select all observations (rows) where the Name column has length 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Print-Example-Select-all-observations-rows-where-the-Name/m-p/743850#M232974</link>
      <description>&lt;P&gt;Assume I have a data set containing a column with different names of some random items.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;First row could be: This_Is_My_First_item&lt;/P&gt;&lt;P&gt;Second row could be:&amp;nbsp;A&lt;/P&gt;&lt;P&gt;Third row could be:&amp;nbsp;ABC&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Now I want to crate a report with all items whose name has length of 1. This is intuitively very simple to do (atleast in other programming languages) but it was not trivial to do for me in SAS.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The solution I used at the end was:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc print data=some_random_data_set;
	 where name like "_";  
run;&lt;/PRE&gt;&lt;P&gt;Any other solutions to this?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Intuitevely (I am currently new to SAS) I wanted to use something like the code below which is some pseudo-code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc print data=some_random_data_set;
	 if length(name) = 1 then print;  
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So the question is:&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Any other (Better?) solutions to this problem?&lt;/P&gt;&lt;P&gt;2. I actually spent quite a lot of time doing this and it is a bit troublesome for me that these kind of simple things are not so straightforward to do nor to find a solution to.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 May 2021 12:54:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Print-Example-Select-all-observations-rows-where-the-Name/m-p/743850#M232974</guid>
      <dc:creator>SasStatistics</dc:creator>
      <dc:date>2021-05-26T12:54:54Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Print Example: Select all observations (rows) where the Name column has length 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Print-Example-Select-all-observations-rows-where-the-Name/m-p/743856#M232978</link>
      <description>&lt;P&gt;You would probably need to use a data step to flag those records that you want to include that only have a length of one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data newfile;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;set yourdata;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;if length(column)=1 then flag=1;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc print data=newfile;&lt;/P&gt;
&lt;P&gt;where flag=1;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 26 May 2021 13:03:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Print-Example-Select-all-observations-rows-where-the-Name/m-p/743856#M232978</guid>
      <dc:creator>CarmineVerrell</dc:creator>
      <dc:date>2021-05-26T13:03:20Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Print Example: Select all observations (rows) where the Name column has length 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Print-Example-Select-all-observations-rows-where-the-Name/m-p/743857#M232979</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/381436"&gt;@SasStatistics&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Assume I have a data set containing a column with different names of some random items.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;First row could be: This_Is_My_First_item&lt;/P&gt;
&lt;P&gt;Second row could be:&amp;nbsp;A&lt;/P&gt;
&lt;P&gt;Third row could be:&amp;nbsp;ABC&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Is the variable of interest NAME? Because you don't really say ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's an example using data set SASHELP.CLASS&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data=sashelp.class;
    where length(name)=4;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If the variable is named something else, then you would make the obvious change to the above code.&lt;/P&gt;</description>
      <pubDate>Wed, 26 May 2021 13:05:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Print-Example-Select-all-observations-rows-where-the-Name/m-p/743857#M232979</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-05-26T13:05:18Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Print Example: Select all observations (rows) where the Name column has length 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Print-Example-Select-all-observations-rows-where-the-Name/m-p/743858#M232980</link>
      <description>The variable of interest is NAME.&lt;BR /&gt;&lt;BR /&gt;This solution is what I intuitively wanted to do. Thanks.</description>
      <pubDate>Wed, 26 May 2021 13:09:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Print-Example-Select-all-observations-rows-where-the-Name/m-p/743858#M232980</guid>
      <dc:creator>SasStatistics</dc:creator>
      <dc:date>2021-05-26T13:09:51Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Print Example: Select all observations (rows) where the Name column has length 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Print-Example-Select-all-observations-rows-where-the-Name/m-p/743861#M232981</link>
      <description>&lt;P&gt;You can call functions in WHERE statements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that LENGTH() will return 1 when the value is empty (all blanks).&amp;nbsp; If you want to also exclude the empty strings you can use LENGTHN() function instead and it will instead return 0 for empty strings.&lt;/P&gt;</description>
      <pubDate>Wed, 26 May 2021 13:12:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Print-Example-Select-all-observations-rows-where-the-Name/m-p/743861#M232981</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-26T13:12:02Z</dc:date>
    </item>
  </channel>
</rss>

