Reputation: 33
“Client_ID_12_months_bill.txt” contains the 12 months credit card bill against each client_id in single Import the data into SAS such that bill for each month is recorded as a separate observation and month number is also specific (Bonus question – Month name instead of month number)
In this Ques, i have Imported the data successfully.But the problem Which I am facing is that,i am not getting the value in Variable-'Balance' (instead of getting correct output i am getting only 1 in each and every observation of Variable-Balance).
108263 $946.00 $903.00 $804.00 $674.00 $663.00 $195.00 $922.00 $595.00 $157.00 $415.00 $868.00 $750.00
103681 $135.00 $573.00 $642.00 $208.00 $922.00 $592.00 $425.00 $658.00 $131.00 $648.00 $750.00 $515.00
116865 $624.00 $679.00 $402.00 $636.00 $358.00 $560.00 $884.00 $514.00 $565.00 $278.00 $117.00 $852.00
102998 $747.00 $505.00 $549.00 $942.00 $884.00 $991.00 $480.00 $326.00 $447.00 $617.00 $721.00 $874.00
115569 $254.00 $792.00 $420.00 $642.00 $851.00 $258.00 $872.00 $828.00 $658.00 $260.00 $499.00 $575.00
data Client_Bill (keep=client_ID balance month_num month_name i );
infile '/folders/myfolders/SAS Assignment/Assignment 8 files
Part-2/Client_ID_12_months_bill.txt' truncover;
informat month1-month12 Dollar6.2;
input client_ID $ month1-month12;
array months(*) month1-month12;
do i=1 to dim(months);
if not missing(months(i)) then do;
balance=month(i);
month_num=i;
month_name=put(mdy(i,1,2017),monname.);
output;
end;
end;
run;
Upvotes: 0
Views: 33
Reputation: 217
Quite simply, balance is defined as the value returned from the function month
(note the singular form), not an element of the array months (plural form).
The month
functions returns the number of a month, given a date. i is interpreted as a date, ie the number of days after 01JAN1960. You are giving it the values 1-12, which are all in January 1960. Thus, it returns month number 1 for all of them.
Upvotes: 1