Converting Date, Price format in SAS

Chapter 3
Question 10 : Stock Stock symbol 1 4 Char
PurDate Purchase date 5 10 mm/dd/yyyy
PurPrice Purchase price 15 6 Dollar signs and
Number Number of shares 21 4 Num
SellDate Selling date 25 10 mm/dd/yyyy
SellPrice Selling price 35 6 Dollar signs and
Author Name : Shruti Goyal

data stocks1;
infile 'd:\sas\stockprices.txt' dsd;
input @1 Stock                   $4.
        @5 PurDate          mmddyy10.
        @15 PurPrice      dollar6.
        @21 Number        4.
        @25 SellDate           mmddyy10.
        @35 SellPrice       dollar6.
        TotalPur  = Number * PurPrice;
        TotalSell = Number * SellPrice;
        Prfit            = TotalSell-TotalPur;
title 'Old format display';
proc print data=stocks1;
Format PurDate date9.
         SellDate date6.
         SellPrice dollar6.
         PurPrice dollar6.
         Profit dollar7.2;


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: