05-30-2012 04:01 PM
I'm relatively new to SAS but just wondering if SAS has the ability to add record.
I have an Excel table contain lines of records. Because we need to make information complete, for each record in an Excel table, I need to add one additional line based on few logics. (I can do this manually, but it takes long to complete)
I know that an Excel macro can help me do the job if my logics are correctly built in, but in a general sense, does SAS have the ability to add record into existing record table? Not sure if I'm asking the right people.
05-30-2012 05:46 PM
Yes, SAS can append records to an Excel dataset. There are at least two methods. Try the following (after adjusting the file path to your environment) :
libname xl excel "&sasForum.\datasets\addRecord.xlsx" scan_text=no;
do x = 1 to 10;
do x = 11 to 20;
proc append base=xl.one data=two; run;
do x = 21 to 30;
insert into xl.one select * from three;
libname xl clear;
05-31-2012 09:24 AM
Thanks for your response.
If you have a moment to spare, my problem is described in the attached file.
This table is the initial record table into which one additional record needs to be added.
the following table shows the added record
So, the logic is....whenever the break down necessary column shows a y, then we need to add a row ABOVE. The first row in the 2nd table remains the same. On the added line as you can see, the start_date becomes the end_date of the previous line, and its end_date is whenever the original end_date was. On the 3rd line, the start_date and end_date is the same in this case. All three lines will have the same admission_date assigned. We get 60 for the days_counted because it's just the subtraction of start_date from end_date.
I know it may seem redundant the way that record needs to be inserted, but it will satisfy our reporting standard.
Anyone able to assist? Can this be done in SAS platform?