<?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 how to a variable from another variable with some values leading blank space in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-a-variable-from-another-variable-with-some-values-leading/m-p/566090#M159038</link>
    <description>&lt;P&gt;Dear,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to create a variable with some values containing leading values.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;output needed in dataset '&lt;FONT color="#FF6600"&gt;two&lt;/FONT&gt;'&amp;nbsp; for variable '&lt;FONT color="#FF6600"&gt;c&lt;/FONT&gt;'&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF6600"&gt;c&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;all&lt;/P&gt;
&lt;P&gt;&amp;nbsp; aaa&lt;/P&gt;
&lt;P&gt;&amp;nbsp; bbb&lt;/P&gt;
&lt;P&gt;&amp;nbsp; ddd&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the above output,&amp;nbsp; i need to have leading blanks for all except first value &lt;FONT color="#FF6600"&gt;'all'.&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;FONT color="#000000"&gt;Please suggest. Thank you&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;BR /&gt;data one;
input a b$;
datalines;
1 all
2 aaa
3 bbb
4 ddd
;
data two;
set one;
if a=1 then c=a;
else c=  a;
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>Thu, 13 Jun 2019 23:47:56 GMT</pubDate>
    <dc:creator>knveraraju91</dc:creator>
    <dc:date>2019-06-13T23:47:56Z</dc:date>
    <item>
      <title>how to a variable from another variable with some values leading blank space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-a-variable-from-another-variable-with-some-values-leading/m-p/566090#M159038</link>
      <description>&lt;P&gt;Dear,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to create a variable with some values containing leading values.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;output needed in dataset '&lt;FONT color="#FF6600"&gt;two&lt;/FONT&gt;'&amp;nbsp; for variable '&lt;FONT color="#FF6600"&gt;c&lt;/FONT&gt;'&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF6600"&gt;c&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;all&lt;/P&gt;
&lt;P&gt;&amp;nbsp; aaa&lt;/P&gt;
&lt;P&gt;&amp;nbsp; bbb&lt;/P&gt;
&lt;P&gt;&amp;nbsp; ddd&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the above output,&amp;nbsp; i need to have leading blanks for all except first value &lt;FONT color="#FF6600"&gt;'all'.&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;FONT color="#000000"&gt;Please suggest. Thank you&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;BR /&gt;data one;
input a b$;
datalines;
1 all
2 aaa
3 bbb
4 ddd
;
data two;
set one;
if a=1 then c=a;
else c=  a;
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>Thu, 13 Jun 2019 23:47:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-a-variable-from-another-variable-with-some-values-leading/m-p/566090#M159038</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2019-06-13T23:47:56Z</dc:date>
    </item>
    <item>
      <title>Re: how to a variable from another variable with some values leading blank space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-a-variable-from-another-variable-with-some-values-leading/m-p/566096#M159041</link>
      <description>&lt;P&gt;If you just want a leading space I would use the cat function. I would also use strip to make sure that there are no spaces to begin with in the variable a.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data two;
set one;
if a=1 then c=a;
else c=  cat(" ",strip(a));
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Or am I missing something more?&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2019 00:52:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-a-variable-from-another-variable-with-some-values-leading/m-p/566096#M159041</guid>
      <dc:creator>heffo</dc:creator>
      <dc:date>2019-06-14T00:52:22Z</dc:date>
    </item>
    <item>
      <title>Re: how to a variable from another variable with some values leading blank space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-a-variable-from-another-variable-with-some-values-leading/m-p/566099#M159044</link>
      <description>What do you need the leading blanks for? PROC REPORT now has an indent option within the style or somewhere at least that can control indents. &lt;BR /&gt;</description>
      <pubDate>Fri, 14 Jun 2019 02:11:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-a-variable-from-another-variable-with-some-values-leading/m-p/566099#M159044</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-06-14T02:11:39Z</dc:date>
    </item>
    <item>
      <title>Re: how to a variable from another variable with some values leading blank space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-a-variable-from-another-variable-with-some-values-leading/m-p/566126#M159057</link>
      <description>&lt;P&gt;Blanks in code are never blanks in data. Blanks in code are just separators between code elements. To have blanks as data, you need to make that clear to the data step compiler by using quotes and the proper concatenation operator:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;a = "  " || a;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that this may cause the truncation of the values in a.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2019 08:07:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-a-variable-from-another-variable-with-some-values-leading/m-p/566126#M159057</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-06-14T08:07:06Z</dc:date>
    </item>
  </channel>
</rss>

