BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
wiphil
SAS Employee

I'm trying to read a raw data file with abbreviated currency values like:

 

1 Exxon Mobil United States $433.5B $41.1B $331.1B $407.4B
2 JPMorgan Chase United States $110.8B $19B $2,265.8B $170.1B

 

Attached is actual raw data file.  I cannot get the data in correctly...the following code is about as close to success as I have gotten:

 

data BigCompanies;
infile 'c:\projectdata\BigCompanies.dat';
input rank 3. company $ 6-31 country $ 35-49 @'$' sales dollar5.1 
@'$' profits dollar5.1 @'$' assets dollar5.1 @'$' market dollar5.1;
run;

 

Struggling...thinking I must be making this harder than it needs to be and would appreciate any assistance.

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
data have;
infile '/folders/myfolders/BigCompanies.txt' truncover expandtabs;
input rank company & $40. country & $40. 
(_sales _profits  _assets  _market) (: $40.) ;
 sales =input(compress(_sales,'B'),dollar32.);
 profits =input(compress(_profits ,'B'),dollar32.);
 assets =input(compress(_assets ,'B'),dollar32.);
 market =input(compress(_market ,'B'),dollar32.);
drop _:;
run;

View solution in original post

1 REPLY 1
Ksharp
Super User
data have;
infile '/folders/myfolders/BigCompanies.txt' truncover expandtabs;
input rank company & $40. country & $40. 
(_sales _profits  _assets  _market) (: $40.) ;
 sales =input(compress(_sales,'B'),dollar32.);
 profits =input(compress(_profits ,'B'),dollar32.);
 assets =input(compress(_assets ,'B'),dollar32.);
 market =input(compress(_market ,'B'),dollar32.);
drop _:;
run;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 854 views
  • 0 likes
  • 2 in conversation