You need to change how the data is on the line so that it can be parsed. You can
Put the data in fixed columns
data example;
input id 1-4 Company $ 5-24 Employees 35-39 Profit comma15.;
format Profit dollar15.;
*---5---10----5---20----5---30----5---40----5---40 ;
datalines;
1 Kling Inc 240 $6641679.60
2 Thompson-Okuneva 348 $8235180.28
;
Use a delimiter between the fields that does not appear in any of the field values
data example;
infile datalines dsd dlm='|' truncover;
input id Company :$40. Employees Profit :comma.;
format Profit dollar15.;
datalines;
1|Kling Inc|240|$6641679.60
2|Thompson-Okuneva|348|$8235180.28
;
Use quotes around the values that include delimiter or quotes (the default delimiter is a space, but when use DSD option default delimiter is a comma)
data example;
infile datalines dsd dlm=' ' truncover;
input id Company :$40. Employees Profit :comma.;
format Profit dollar15.;
datalines;
1 "Kling Inc" 240 $6641679.60
2 Thompson-Okuneva 348 $8235180.28
;
Put at least two delimiters after values that include the delimiter and use the & modifier in the INPUT statement. Note that the values cannot have two or more adjacent delimiters.
data example;
input id Company &:$40. Employees Profit :comma.;
format Profit dollar15.;
datalines;
1 Kling Inc 240 $6641679.60
2 Thompson-Okuneva 348 $8235180.28
;
A couple of other notes.
Place the semi-colon that ends the in-line data after the last line of data.
If you put it on one of the lines of data it means that line will be ignored. If you are using a SAS aware editor the color highlighting should help you see that mistake:
You appear to be trying to use the INFORMAT statement as a way to define the variables. SAS will define the variables in the order it first sees them (at the least the first place it needs to know how they are defined). So using INFORMAT in this way is just using that side effect to define the variables. It is clearer to define the variables in advance using a LENGTH statement (or an ATTRIB statement with the LENGTH= attribute). In code above I have just let SAS define the variables as it sees them in the INPUT statement, but for the delimited examples I have use an in-line INFORMAT in the INPUT statement to give SAS a hint for how long to create the character variables because otherwise the default length would be $8. Remember to use : modifier before any informat specifications when reading delimited data (list mode input) so that SAS only reads the number of characters that they values uses on that line. Otherwise the informat might cause it to read too few or too many characters and then be out of position for when it tries to read the next field on the line.
Informats are instructions for how to convert text to values. SAS only needs you to tell it to use a specific informat in rare cases. The main place where you need informats is for reading DATE, TIME or DATETIME values. Another is, as in your example, when there are commas and dollar signs in a numeric field you will need to use the COMMA informat (you can also call the comma informat by its alias of dollar).
Formats are instructions for how to convert values to text. Again you rarely need to attach formats to your variables. The main exception is DATE, TIME and DATETIME values. Or if you want the values to print in a particular style, like the DOLLAR format in your example. But be careful with attaching formats to variables as it can cause unexpected behavior if the values are not compatible with the format attached to them. For example if any of the count of EMPLOYEES in your dataset was larger then 9,999 and you had attached the 4. format as in your example it would switch to use scientific notation.
264 data _null_;
265 Employees = 12345 ;
266 put Employees= 4.;
267 run;
Employees=12E3
... View more