My code and format was correct, however i had to modify the .csv file. It needed to read from left to right. Gender Wages Population 20 female entries $1-2499 or loss 7 20 male entries $2500-$4999 0 All the way down, the 40 entries were then split in half top end and bottom end. The following code resolved it. I always do something silly...., i just had to change my .csv file and this thing worked like a charm. Data scan;
*call routine, Returns the position and length of the nth word from a character string. ;
*creation of data step in week 4;
infile '.csv' DSD firstobs=2;
*location of file for analysis, tells SAS to start reading at line 2;
Length Gender $7;
*character to list in length for gender, male or female;
Length Earnings $20;
*character to list in length for amounts earned, high and low;
Length Population 7.0;
*total population in that wage range, up to 7 digits;
Input Gender $ Earnings $ Population;
*framework of table, the three headings;
Low_wages=scan(Earnings,1,' ');
*SAS Institute. (2017). SCAN Function. Retrieved from http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000214639.htm ;
High_Wages=Scan(Earnings,3,' ');
*SAS Institute. (2017). SCAN Function. Retrieved from http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000214639.htm ;
If High_Wages='more' then High_Wages='149999';
*If, then, else;
*SAS Institue. (2017). SAS Operators In Expressions. Retrieved from http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000780367.htm;
*beginning of the DO loop, set to 40 original readings, with a second 40 to follow;
Data DoLoop;
set scan;
*scan function;
Do i= 1 to 40;
*repeats and reads the entries for 40 values;
Low_wages3=input(Low_Wages, dollar7.0);
*input of low wage end in dollar format up to 7 places;
End;
*Executes statements between the DO and END statements repetitively, based on the value of an index variable;
Do i= 1 to 40;
*repeats and reads the entries for 40 values;
High_Wages3=input(High_Wages, dollar7.0);
*input of low wage end in dollar format up to 7 places;
End;
Proc print;
*provids the results printable to a exportable raw file;
Title 'DO Loop';
*name of file;
Var Gender Low_Wages3 High_Wages3 Population;
*Column heading names;
run;
... View more