<?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: entering data in billions of dollars in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/entering-data-in-billions-of-dollars/m-p/626034#M35573</link>
    <description>&lt;P&gt;thanks!&lt;/P&gt;</description>
    <pubDate>Wed, 19 Feb 2020 23:51:01 GMT</pubDate>
    <dc:creator>Damon1</dc:creator>
    <dc:date>2020-02-19T23:51:01Z</dc:date>
    <item>
      <title>entering data in billions of dollars</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/entering-data-in-billions-of-dollars/m-p/625730#M35554</link>
      <description>&lt;P&gt;Hi Everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Been learning for about a week. So, i have a data set that follows the following pattern:&lt;/P&gt;&lt;P&gt;rank (numeric), company ($), country ($), sales (num), profits (num), assets (num), market value (num)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the data under the last 4 numeric variables are presented in billions of dollars, as "$1.5B" or "$200.1B", and vary in length&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Im using the following code:&lt;/P&gt;&lt;P&gt;DATA bigcos;&lt;BR /&gt;INFILE 'C:\Users\dlobsien\Documents\bigcompanies.txt';&lt;BR /&gt;INPUT ranking company_name $26. +1 country $18. sales_in_billions :dollar10. profits_in_billions :dollar10. assets_in_billions :dollar10. +1 profits_in_billions :dollar10.;&lt;BR /&gt;title companies data;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;——————————-&lt;/P&gt;&lt;P&gt;PROC PRINT data=bigcos (obs=15);&lt;BR /&gt;Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the first three variables go in fine, but it wont read anything after that with the Bs in the way (i assume that's the issue). whenever i add a line that says "compress(var, 'B')", after the input lines it gives me 0 observations—maybe I'm entering the syntax wrong or putting it in the wrong spot.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've also included the data set in case that is useful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2020 00:48:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/entering-data-in-billions-of-dollars/m-p/625730#M35554</guid>
      <dc:creator>Damon1</dc:creator>
      <dc:date>2020-02-19T00:48:21Z</dc:date>
    </item>
    <item>
      <title>Re: entering data in billions of dollars</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/entering-data-in-billions-of-dollars/m-p/625987#M35568</link>
      <description>&lt;P&gt;Read the so called numeric data as char type first:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA bigcos;
INFILE 'C:\Users\dlobsien\Documents\bigcompanies.txt';
INPUT ranking company_name $26. 
      +1 country $18. sales $ profits $ assets $ ;
	
      drop sales profits assets ; /* the char type numeric variables */	
	  
      sales_in_billions  = input(compress(sales,'B'),dollar10.);
      profits_in_billions = inpt(compress(profits,'B'),dollar10.); 
      assets_in_billions  = input(compress(assets,'B'),dollar10.);
	  
      /* +1 profits_in_billions :dollar10.; &amp;lt;&amp;lt;&amp;lt; you can't have two variables with same name ! */

RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Feb 2020 20:43:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/entering-data-in-billions-of-dollars/m-p/625987#M35568</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-02-19T20:43:47Z</dc:date>
    </item>
    <item>
      <title>Re: entering data in billions of dollars</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/entering-data-in-billions-of-dollars/m-p/626012#M35569</link>
      <description>&lt;P&gt;Is it always a B?&amp;nbsp; If so then just ignore it.&lt;/P&gt;
&lt;P&gt;First thing to do is figure out where the data is on the line. The LIST statement is good for that.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  infile "&amp;amp;path\bigcompanies.txt" obs=5;
  input;
  list;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;RULE:     ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+--
1         1    Exxon Mobil                  United States     $433.5B   $41.1B   $331.1B   $407.4B 88
2         2    JPMorgan Chase               United States     $110.8B     $19B $2,265.8B   $170.1B 88
3         3    General Electric             United States     $147.3B   $14.2B   $717.2B   $213.7B 88
4         4    Royal Dutch Shell            Netherlands       $470.2B   $30.9B   $340.5B   $227.6B 88
5         5    ICBC                         China              $82.6B   $25.1B $2,039.1B   $237.4B 88
NOTE: 5 records were read from the infile "xxx\bigcompanies.txt".
&lt;/PRE&gt;
&lt;P&gt;Then you can write a program to read the lines. Make sure to give each variable a UNIQUE name.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data bigcos (label='companies data');
  infile "&amp;amp;path\bigcompanies.txt" truncover;
  input ranking 1-5
        company_name $ 6-34
        country $ 35-49 
    @51 sales_in_billions dollar8. 
    @60 profits_in_billions dollar8. 
    @69 assets_in_billions dollar8. 
    @79 profits_in_billions2 dollar9.
  ;
  format sales_in_billions -- profits_in_billions2 dollar10.1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Feb 2020 21:51:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/entering-data-in-billions-of-dollars/m-p/626012#M35569</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-02-19T21:51:43Z</dc:date>
    </item>
    <item>
      <title>Re: entering data in billions of dollars</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/entering-data-in-billions-of-dollars/m-p/626025#M35570</link>
      <description>&lt;P&gt;I believe that your problem is that several of the company names include accents, which are probably taking up more than one byte if you're not reading them correctly. This is pushing your columns out of line.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This second comment is a little advanced, but file it away for later. When I'm processing formatted data like this, I like to test the variables to ensure that they're well formed. The PRX routines are an easy way to do this (not completely tested).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data TestData;
	length SalesC $15;
	input;
	SalesC = _infile_;
	cards;
$433.5B
$110.8B
147.3B
 $470.2B
 $82.6B
  $102B
$310.1B
$310.B
 143.7B
 $87.6B
 $145.9
$375.5B
$.3B
 $68.7B
run;

data Problems(drop=_:);
	retain _RX1;

	if _n_ = 1 then
		_RX1 = prxparse("~^[[:space:]]*\$[[:digit:]]+(\.[[:digit:]])?B[[:space:]]*$~");
	set TestData;

	if ^prxmatch(_RX1, SalesC) then
		output;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Feb 2020 22:51:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/entering-data-in-billions-of-dollars/m-p/626025#M35570</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2020-02-19T22:51:09Z</dc:date>
    </item>
    <item>
      <title>Re: entering data in billions of dollars</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/entering-data-in-billions-of-dollars/m-p/626028#M35571</link>
      <description>&lt;P&gt;yeah this is what i did. i then used compress to take out the $,B and converted it to numeric in a new data set using the best. format&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2020 23:11:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/entering-data-in-billions-of-dollars/m-p/626028#M35571</guid>
      <dc:creator>Damon1</dc:creator>
      <dc:date>2020-02-19T23:11:53Z</dc:date>
    </item>
    <item>
      <title>Re: entering data in billions of dollars</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/entering-data-in-billions-of-dollars/m-p/626033#M35572</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/312620"&gt;@Damon1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;yeah this is what i did. i then used compress to take out the $,B and converted it to numeric in a new data set using the best. format&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You convert from text to values using an INFORMAT, not a FORMAT.&amp;nbsp; BEST is a format but if you try to use it as in informat SAS will just go ahead and use the normal numeric informat instead.&amp;nbsp; If you use the COMMA informat there is no need to remove the dollar signs or commas as that informat will strip those for you.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2020 23:49:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/entering-data-in-billions-of-dollars/m-p/626033#M35572</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-02-19T23:49:16Z</dc:date>
    </item>
    <item>
      <title>Re: entering data in billions of dollars</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/entering-data-in-billions-of-dollars/m-p/626034#M35573</link>
      <description>&lt;P&gt;thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2020 23:51:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/entering-data-in-billions-of-dollars/m-p/626034#M35573</guid>
      <dc:creator>Damon1</dc:creator>
      <dc:date>2020-02-19T23:51:01Z</dc:date>
    </item>
  </channel>
</rss>

