Hello, I'm trying to use SAS to acquire data from the internet. More specifically, I'm interested in financial data on publicly traded companies. I have code which downloads the financial information. This part works fine. The issue is that the data may span across several observations. My plan to is tag all the observations with relevant data and then use proc transpose to combine the multiple observations into one observation where I can use nested if statements and substrate/index functions to extract the information. I'm attempting to use a DO UNTIL loop to mark the records with relevant information, but can't get it to work properly. My program crashes whenever the data spans across more than one observation. Please see my code below. Does anyone have an idea of what I'm doing wrong? Any help or advice would be greatly appreciated. Thanks so much! Regards, Bill *DOWNLOAD FINANCIAL DATA; filename in url 'http://finance.yahoo.com/q/bs?s=AAPL' debug lrecl=8192; DATA OUT.YAHOO_HTML; infile in length=len; input record $varying8192. len; RUN; *PARSE HTML; %MACRO BAL_SHEET_ITEM(YAHOO_NAME,SAS_NAME); DATA OUT.&SAS_NAME.1; SET OUT.YAHOO_HTML; SYMBOL='AAPL'; *LIMIT DATA SET TO RECORDS WITH RELEVANT INFO; KEEPDATA = 0; %LET BEG_DATA=INDEX(record,&YAHOO_NAME.); /* BEGINNING OF DATA*/ %LET END_DATA=index(record,' </td></tr><tr>');/*END OF DATA*/ IF &BEG_DATA. > 0 THEN DO UNTIL (&END_DATA.>0); KEEPDATA=1; END; IF KEEPDATA=1; RUN; %MEND; %BAL_SHEET_ITEM('Cash And Cash Equivalents',CASH_AND_EQUIV); %BAL_SHEET_ITEM('Inventory',INVENTORY); %BAL_SHEET_ITEM('Short Term Investments',SHORT_TERM_ASSETS); %BAL_SHEET_ITEM('Net Receivables',NET_REC); %BAL_SHEET_ITEM('Inventory',INVENTORY); %BAL_SHEET_ITEM('Other Current Assets',OTH_CURR_ASSETS); %BAL_SHEET_ITEM('Accounts Payable',ACCTS_PAYABLE); %BAL_SHEET_ITEM('Short/Current Long Term Debt',SHORT_CURR_LT_DEBT); %BAL_SHEET_ITEM('Other Current Liabilities',OTH_CURR_LIAB); %BAL_SHEET_ITEM('Long Term Debt',LT_DEBT); %BAL_SHEET_ITEM('Other Liabilities',OTH_LIAB); %BAL_SHEET_ITEM('Deferred Long Term Liability Charges',DEF_LT_LIAB); %BAL_SHEET_ITEM('Minority Interest',MIN_INT); %BAL_SHEET_ITEM('Negative Goodwill',NEG_GOODWILL);
... View more