<?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: Left justifying or left aligning values of a variable in a data set in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Left-justifying-or-left-aligning-values-of-a-variable-in-a-data/m-p/662501#M22749</link>
    <description>&lt;P&gt;Please show what the CSV file looks like, what you posted looks like a printout or a spreadsheet, a CSV file is text delimited with commas.&lt;/P&gt;
&lt;P&gt;If you used PROC IMPORT to read the CSV file and the values in the ID variable only include digits, like in your example printout, then PROC IMPORT will assume the value is numeric.&amp;nbsp; Just write your own data step to read the file so you can control what type of variable is created.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  infile 'myfile.csv' dsd truncover firstobs=2;
  input pcode :$6.  id :$12.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 18 Jun 2020 04:47:17 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2020-06-18T04:47:17Z</dc:date>
    <item>
      <title>Left justifying or left aligning values of a variable in a data set</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Left-justifying-or-left-aligning-values-of-a-variable-in-a-data/m-p/662001#M22746</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I am trying to use a special SAS code. In order to use it I have to have a data set with 2 variables ID and PCODE. ID is $12 and PCODE is a $6. I am importing this data set from a csv file using proc import.&amp;nbsp; The csv file looks like this:&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 102pt;" border="0" width="136" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD width="68" height="19" style="height: 14.25pt; width: 51pt;"&gt;pcode&lt;/TD&gt;
&lt;TD width="68" style="width: 51pt;"&gt;id&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" style="height: 14.25pt;"&gt;T0B3M2&lt;/TD&gt;
&lt;TD align="right"&gt;724806&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" style="height: 14.25pt;"&gt;T0L0K0&lt;/TD&gt;
&lt;TD align="right"&gt;2241906&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" style="height: 14.25pt;"&gt;T0K2S0&lt;/TD&gt;
&lt;TD align="right"&gt;2559858&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" style="height: 14.25pt;"&gt;T1M0B1&lt;/TD&gt;
&lt;TD align="right"&gt;3115006&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" style="height: 14.25pt;"&gt;T6L4S4&lt;/TD&gt;
&lt;TD align="right"&gt;4527226&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" style="height: 14.25pt;"&gt;T5R1E9&lt;/TD&gt;
&lt;TD align="right"&gt;6093226&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" style="height: 14.25pt;"&gt;T2A6K3&lt;/TD&gt;
&lt;TD align="right"&gt;6927026&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" style="height: 14.25pt;"&gt;T8V7G7&lt;/TD&gt;
&lt;TD align="right"&gt;7186848&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" style="height: 14.25pt;"&gt;T7S1N9&lt;/TD&gt;
&lt;TD align="right"&gt;8380906&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" style="height: 14.25pt;"&gt;T0L1R0&lt;/TD&gt;
&lt;TD align="right"&gt;9075136&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" style="height: 14.25pt;"&gt;T0E2M0&lt;/TD&gt;
&lt;TD align="right"&gt;9232706&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" style="height: 14.25pt;"&gt;T0H3C0&lt;/TD&gt;
&lt;TD align="right"&gt;10004336&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" style="height: 14.25pt;"&gt;T5X1G5&lt;/TD&gt;
&lt;TD align="right"&gt;10106718&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" style="height: 14.25pt;"&gt;T8L5G3&lt;/TD&gt;
&lt;TD align="right"&gt;10682226&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" style="height: 14.25pt;"&gt;T8A1R5&lt;/TD&gt;
&lt;TD align="right"&gt;13721906&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" style="height: 14.25pt;"&gt;T3E7C4&lt;/TD&gt;
&lt;TD align="right"&gt;15817336&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I am unable to make the main SAS code that is supposed to use this data set as input to work. Someone has suggested that I should make the ID values left-justified.&amp;nbsp; Aren't all the character values in SAS automatically left-justified? If not how can I left-justify them? I have attached the data set that I have made from the csv file here. BTW, I am using SAS 9.4.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks,&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2020 01:19:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Left-justifying-or-left-aligning-values-of-a-variable-in-a-data/m-p/662001#M22746</guid>
      <dc:creator>Primavera</dc:creator>
      <dc:date>2020-06-18T01:19:31Z</dc:date>
    </item>
    <item>
      <title>Re: Left justifying or left aligning values of a variable in a data set</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Left-justifying-or-left-aligning-values-of-a-variable-in-a-data/m-p/662474#M22747</link>
      <description>&lt;P&gt;Internal sas datasets' structure is different per OS, so posting a sas dataset doesn'n help much.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Char-type variables which are imported by PROC IMPORT are left justified.&lt;/P&gt;
&lt;P&gt;Check by PROC CONTENTS is PCODE realy a char-type or numeric.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please explain what issue you have because of justification, what code&lt;/P&gt;
&lt;P&gt;you try to run and what are the results v.s. the expected results.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2020 04:38:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Left-justifying-or-left-aligning-values-of-a-variable-in-a-data/m-p/662474#M22747</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-06-18T04:38:59Z</dc:date>
    </item>
    <item>
      <title>Re: Left justifying or left aligning values of a variable in a data set</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Left-justifying-or-left-aligning-values-of-a-variable-in-a-data/m-p/662475#M22748</link>
      <description>&lt;P&gt;It will depend on how a variable is created whether it will have leading spaces or not. Proc Import is not very bright. Look in your CSV file and see if the ID values appear in quotes like&lt;/P&gt;
&lt;PRE&gt;"T0B3M2","      724806"&lt;/PRE&gt;
&lt;P&gt;Your values in that data set have leading spaces.&lt;/P&gt;
&lt;PRE&gt;data _null_;&lt;BR /&gt;   set postcode4 (obs=1);&lt;BR /&gt;   z=length(id);&lt;BR /&gt;   a = length(strip(id));&lt;BR /&gt;   put 'ID length is ' z 'length without leading spaces is ' a ;&lt;BR /&gt;run;&lt;/PRE&gt;
&lt;P&gt;The log will show how long the first value of the ID variable as is&amp;nbsp; and after removing the leading spaces.&lt;/P&gt;
&lt;P&gt;Good news is that it is easy to get rid of them:&lt;/P&gt;
&lt;PRE&gt;Data want;
   set postcode4;
   id=strip(id);
run;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Thu, 18 Jun 2020 04:39:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Left-justifying-or-left-aligning-values-of-a-variable-in-a-data/m-p/662475#M22748</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-18T04:39:18Z</dc:date>
    </item>
    <item>
      <title>Re: Left justifying or left aligning values of a variable in a data set</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Left-justifying-or-left-aligning-values-of-a-variable-in-a-data/m-p/662501#M22749</link>
      <description>&lt;P&gt;Please show what the CSV file looks like, what you posted looks like a printout or a spreadsheet, a CSV file is text delimited with commas.&lt;/P&gt;
&lt;P&gt;If you used PROC IMPORT to read the CSV file and the values in the ID variable only include digits, like in your example printout, then PROC IMPORT will assume the value is numeric.&amp;nbsp; Just write your own data step to read the file so you can control what type of variable is created.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  infile 'myfile.csv' dsd truncover firstobs=2;
  input pcode :$6.  id :$12.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Jun 2020 04:47:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Left-justifying-or-left-aligning-values-of-a-variable-in-a-data/m-p/662501#M22749</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-06-18T04:47:17Z</dc:date>
    </item>
    <item>
      <title>Re: Left justifying or left aligning values of a variable in a data set</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Left-justifying-or-left-aligning-values-of-a-variable-in-a-data/m-p/663068#M22751</link>
      <description>&lt;P&gt;When you need to post csv files for reference, do this:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;open the file with a text editor (do &lt;STRONG&gt;NOT&lt;/STRONG&gt; use Excel!)&lt;/LI&gt;
&lt;LI&gt;mark the first few lines completely; enough so that edge cases (if present in the file) are covered&lt;/LI&gt;
&lt;LI&gt;copy the text to the clipboard&lt;/LI&gt;
&lt;LI&gt;open a subwindow with this button:&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg"&gt;&lt;img src="https://communities.sas.com/skins/images/70F8802BAA6255D55FBEC62A8226FB10/responsive_peak/images/image_not_found.png" alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" /&gt;&lt;/span&gt;&lt;/LI&gt;
&lt;LI&gt;paste the text into this window&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I inspected your dataset and found that id is in fact character with a length of 12. So I ran this code to left-justify it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data pcode;
set postcode4;
id = left(id);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2020 07:38:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Left-justifying-or-left-aligning-values-of-a-variable-in-a-data/m-p/663068#M22751</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-18T07:38:00Z</dc:date>
    </item>
    <item>
      <title>Re: Left justifying or left aligning values of a variable in a data set</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Left-justifying-or-left-aligning-values-of-a-variable-in-a-data/m-p/664793#M22881</link>
      <description>&lt;P&gt;Hello again,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;thank you for your help and advice. Your code worked perfectly. But it seems my problem is deeper than that. I am trying to use a program called&amp;nbsp; PCCFPlus_7C that was created by Stats Canada. I need to use it to get some statistical info about some study participants based on their postal codes. When I try to open the program I get:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Primavera_0-1593035159671.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/46608i5D2D48D2349AB461/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Primavera_0-1593035159671.png" alt="Primavera_0-1593035159671.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The result is that many of the lines in the program are truncated and thus the program does not work. Since you are a super user do you know how I can fix this issue? I am using&amp;nbsp; SAS 9.4 (Unicode Support) and my OS is Windows 10 (64-bit).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many Thanks&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jun 2020 21:51:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Left-justifying-or-left-aligning-values-of-a-variable-in-a-data/m-p/664793#M22881</guid>
      <dc:creator>Primavera</dc:creator>
      <dc:date>2020-06-24T21:51:33Z</dc:date>
    </item>
    <item>
      <title>Re: Left justifying or left aligning values of a variable in a data set</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Left-justifying-or-left-aligning-values-of-a-variable-in-a-data/m-p/664794#M22882</link>
      <description>&lt;P&gt;Hello again,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;thank you for your help. I am figuring out that my problem is deeper than left-justification of my data. I am trying to use a program called&amp;nbsp; PCCFPlus_7C that was created by Stats Canada. I need to use it to get some statistical info about some study participants based on their postal codes. When I try to open the program I get:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Primavera_0-1593035159671.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/46608i5D2D48D2349AB461/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Primavera_0-1593035159671.png" alt="Primavera_0-1593035159671.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The result is that many of the lines in the program are truncated and thus the program does not work. Do you know how I can fix this issue? I am using&amp;nbsp; SAS 9.4 (Unicode Support) and my OS is Windows 10 (64-bit).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many Thanks&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jun 2020 21:53:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Left-justifying-or-left-aligning-values-of-a-variable-in-a-data/m-p/664794#M22882</guid>
      <dc:creator>Primavera</dc:creator>
      <dc:date>2020-06-24T21:53:25Z</dc:date>
    </item>
    <item>
      <title>Re: Left justifying or left aligning values of a variable in a data set</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Left-justifying-or-left-aligning-values-of-a-variable-in-a-data/m-p/664811#M22883</link>
      <description>&lt;P&gt;The message "... lines included ..." means there is a statement starting with &lt;STRONG&gt;%include &lt;/STRONG&gt;- followed with a text file name containing some code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Locate that code &amp;lt;file name&amp;gt;.sas and open with notepad or notepad++,&lt;/P&gt;
&lt;P&gt;locate the long lines and split them and finally save.&lt;/P&gt;
&lt;P&gt;If you saved it in a different name then the original, don't forget to change&lt;/P&gt;
&lt;P&gt;that statement starting with &lt;STRONG&gt;%include&lt;/STRONG&gt; to the new name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;%include&lt;/STRONG&gt; could be abbreviated as &lt;STRONG&gt;%inc.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then run your program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jun 2020 00:05:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Left-justifying-or-left-aligning-values-of-a-variable-in-a-data/m-p/664811#M22883</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-06-25T00:05:38Z</dc:date>
    </item>
    <item>
      <title>Re: Left justifying or left aligning values of a variable in a data set</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Left-justifying-or-left-aligning-values-of-a-variable-in-a-data/m-p/664812#M22884</link>
      <description>&lt;P&gt;What gave you that pop-up error message?&lt;/P&gt;
&lt;P&gt;Did you try to include the file into the program editor window in SAS Display Manager?&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jun 2020 00:09:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Left-justifying-or-left-aligning-values-of-a-variable-in-a-data/m-p/664812#M22884</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-06-25T00:09:12Z</dc:date>
    </item>
    <item>
      <title>Re: Left justifying or left aligning values of a variable in a data set</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Left-justifying-or-left-aligning-values-of-a-variable-in-a-data/m-p/664816#M22885</link>
      <description>&lt;P&gt;I just tried to open the program in&lt;SPAN&gt;&amp;nbsp;the program editor window in SAS Display Manager. Nothing fancy. I have done that with my own codes at least 500 times before and never had seen this error.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jun 2020 00:35:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Left-justifying-or-left-aligning-values-of-a-variable-in-a-data/m-p/664816#M22885</guid>
      <dc:creator>Primavera</dc:creator>
      <dc:date>2020-06-25T00:35:54Z</dc:date>
    </item>
    <item>
      <title>Re: Left justifying or left aligning values of a variable in a data set</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Left-justifying-or-left-aligning-values-of-a-variable-in-a-data/m-p/664817#M22886</link>
      <description>Awesome. It worked. Thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Thu, 25 Jun 2020 00:37:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Left-justifying-or-left-aligning-values-of-a-variable-in-a-data/m-p/664817#M22886</guid>
      <dc:creator>Primavera</dc:creator>
      <dc:date>2020-06-25T00:37:03Z</dc:date>
    </item>
  </channel>
</rss>

