03-10-2018 01:56 PM
I am trying to change the format of column Gross, which contains values like $50,319,942. I wish to make my program treat this variable as numeric.
This is my code but it is not displaying the values of this column.
INFILE "/folders/myfolders/GrossDays.txt" DLM='09'x MISSOVER FIRSTOBS=2 DSD;
INPUT Title :$100. Date :ANYDTDTE20. Gross Theaters Distributor $;
PROC PRINT DATA=movies;
FORMAT Date DATE9.;
PROC PRINT DATA = music;
FORMAT Date DATE. ;
FORMAT Gross 10. ;
TheaterAvg = (Gross/Theaters);
PROC PRINT DATA = movies;
03-10-2018 02:14 PM
You just need to add an informat when inputting gross. e.g.:
DATA movies; INFILE "/folders/myfolders/GrossDays.txt" DLM='09'x MISSOVER FIRSTOBS=2 DSD; INPUT Title :$100. Date :ANYDTDTE20. Gross dollar12. Theaters Distributor $; RUN;
Art, CEO, AnalystFinder.com
03-10-2018 02:18 PM - edited 03-10-2018 02:20 PM
Make sure to include the : prefix so that it uses list mode input since the source file is delimited and not fixed columns.
INPUT Title :$100. Date :ANYDTDTE. Gross :dollar. Theaters Distributor :$20.;
You don't need widths on your INFORMATs when using list mode, SAS will ignore them.
But you do want to include the width in the $xx. informats since that way SAS can use the width the make a better guess at what length you want the character variables to use.
03-10-2018 02:23 PM