
SAS日志檢測
以前跑數(shù)據(jù)集市時,通常是每天自己批量跑,如果每天查看日志非常麻煩。今天給大家分享一段數(shù)據(jù)日志的檢測代碼,可以判斷是是哪天出錯了。如下圖所示:
[xmy_1487668820/2017-05-05-16-06-49-9355.png]
程序如下:
%macro check_main_log(dizhi);
data rizhi_shujuji3;
infile "&dizhi." end=eof length=length;
input jilu $400. length;
run;
/*將錯誤的記錄找出來,進行排列*/
data xiugai3;
set rizhi_shujuji3 end=w;
retain errcount 0;
jilu=left(trim(jilu));
if jilu=:"ERROR:" or jilu=:"WARNING:" or jilu=:"ERROR" or jilu=:"WARNING" then do;
errcount=errcount+1;
call symput("errcount",errcount);
end;
if w then do;
panduan=errcount;
end;
run;
data c3;
set xiugai3;
if panduan~=.;
%let panduan=panduan;
call symput("panduan",panduan);
run;
/*找出錯誤記錄所在的行數(shù)*/
data xiugai3;
set xiugai3;
retain errfound 0;
if errcount~='' then errfound=errfound+1;
run;
/*排序記錄排列,將錯誤數(shù)據(jù)記錄保留下來*/
proc sort
data=xiugai3;
by errcount;
run;
%if &panduan.=0 %then %do;
data xggg;
length txtname $400. biaoshi $10. jilu $400.;
format errcount best12. errfound best12. up_data best12.;
errcount=0;
errfound=0;
up_data=&t.;
txtname="&dizhi.";
biaoshi="right";
jilu="運行無錯";
label jilu='錯誤記錄' errcount='序列' errfound='錯誤所在行數(shù)' txtname="檢測文件名稱" biaoshi="標(biāo)識";
%end;
run;
/*建立一個基礎(chǔ)數(shù)據(jù)集放到邏輯庫main*/
data main.warning;
length txtname $400. biaoshi $10. jilu $400.;
format errcount best12. errfound best12. up_data best12.;
txtname="";
up_data="";
biaoshi="";
jilu="";
errcount="";
errfound="";
run;
/*將錯誤的記錄放到main邏輯庫*/
proc append
base=main.warning data=xggg force;
quit;
%if &panduan.>1 %then %do;
data xggg;
set xiugai3;
length txtname $400. biaoshi $10. jilu $400.;
format errcount best12. errfound best12. up_data best12.;
by errcount;
txtname="&dizhi";
up_data=&t.;
biaoshi="warning";
if first.errcount;
if errcount~=0;
drop panduan;
label jilu='錯誤記錄' errcount='序列' errfound='錯誤所在行數(shù)' txtname="檢測文件名稱" biaoshi="標(biāo)識";
%end;
run;
/*建立一個基礎(chǔ)數(shù)據(jù)集放到邏輯庫main*/
data main.warning;
length txtname $400. biaoshi $10. jilu $400.;
format errcount best12. errfound best12. up_data best12.;
txtname="";
up_data="";
biaoshi="";
jilu="";
errcount="";
errfound="";
run;
/*講錯誤的記錄放到main邏輯庫*/
proc append
base=main.warning data=xggg force;
quit;
%mend;
********************以下是調(diào)用******************
data time;
format t $8.;
t=compress(year(today())*10000+month(today())*100+day(today()));
call symput('t',t);
run;
/*創(chuàng)建文件夾*/
data _null_;
new = dcreate("&t.","&input.");
new1 = dcreate("結(jié)果數(shù)據(jù)","&input.\&t.");
new2 = dcreate("錯誤數(shù)據(jù)集","&input.\&t.");
new3 = dcreate("log","&input.\&t.");
new4 = dcreate("main","&input.\&t.");
run;
%let canshu = &input.\&t.\錯誤數(shù)據(jù)集;
%let log = &input.\&t.\log;
%let main = &input.\&t.\main;
/*導(dǎo)出日志*/
DM 'LOG;log; FILE "&log.\main.txt" replace;';
run;
/*清除日志*/
DM 'log; "clear";';
/*創(chuàng)建邏輯庫*/
libname canshu "&canshu.";
libname main "&main.";
/*調(diào)用檢測日志的宏程序*/
%check_main_log(&log.\main.txt);
此程序在批量運行中特別方便,只要查看邏輯庫main 里的warning數(shù)據(jù)集就可知道哪里出錯。
數(shù)據(jù)分析咨詢請掃描二維碼
若不方便掃碼,搜微信號:CDAshujufenxi
LSTM 模型輸入長度選擇技巧:提升序列建模效能的關(guān)鍵? 在循環(huán)神經(jīng)網(wǎng)絡(luò)(RNN)家族中,長短期記憶網(wǎng)絡(luò)(LSTM)憑借其解決長序列 ...
2025-07-11CDA 數(shù)據(jù)分析師報考條件詳解與準備指南? ? 在數(shù)據(jù)驅(qū)動決策的時代浪潮下,CDA 數(shù)據(jù)分析師認證愈發(fā)受到矚目,成為眾多有志投身數(shù) ...
2025-07-11數(shù)據(jù)透視表中兩列相乘合計的實用指南? 在數(shù)據(jù)分析的日常工作中,數(shù)據(jù)透視表憑借其強大的數(shù)據(jù)匯總和分析功能,成為了 Excel 用戶 ...
2025-07-11尊敬的考生: 您好! 我們誠摯通知您,CDA Level I和 Level II考試大綱將于 2025年7月25日 實施重大更新。 此次更新旨在確保認 ...
2025-07-10BI 大數(shù)據(jù)分析師:連接數(shù)據(jù)與業(yè)務(wù)的價值轉(zhuǎn)化者? ? 在大數(shù)據(jù)與商業(yè)智能(Business Intelligence,簡稱 BI)深度融合的時代,BI ...
2025-07-10SQL 在預(yù)測分析中的應(yīng)用:從數(shù)據(jù)查詢到趨勢預(yù)判? ? 在數(shù)據(jù)驅(qū)動決策的時代,預(yù)測分析作為挖掘數(shù)據(jù)潛在價值的核心手段,正被廣泛 ...
2025-07-10數(shù)據(jù)查詢結(jié)束后:分析師的收尾工作與價值深化? ? 在數(shù)據(jù)分析的全流程中,“query end”(查詢結(jié)束)并非工作的終點,而是將數(shù) ...
2025-07-10CDA 數(shù)據(jù)分析師考試:從報考到取證的全攻略? 在數(shù)字經(jīng)濟蓬勃發(fā)展的今天,數(shù)據(jù)分析師已成為各行業(yè)爭搶的核心人才,而 CDA(Certi ...
2025-07-09【CDA干貨】單樣本趨勢性檢驗:捕捉數(shù)據(jù)背后的時間軌跡? 在數(shù)據(jù)分析的版圖中,單樣本趨勢性檢驗如同一位耐心的偵探,專注于從單 ...
2025-07-09year_month數(shù)據(jù)類型:時間維度的精準切片? ? 在數(shù)據(jù)的世界里,時間是最不可或缺的維度之一,而year_month數(shù)據(jù)類型就像一把精準 ...
2025-07-09CDA 備考干貨:Python 在數(shù)據(jù)分析中的核心應(yīng)用與實戰(zhàn)技巧? ? 在 CDA 數(shù)據(jù)分析師認證考試中,Python 作為數(shù)據(jù)處理與分析的核心 ...
2025-07-08SPSS 中的 Mann-Kendall 檢驗:數(shù)據(jù)趨勢與突變分析的有力工具? ? ? 在數(shù)據(jù)分析的廣袤領(lǐng)域中,準確捕捉數(shù)據(jù)的趨勢變化以及識別 ...
2025-07-08備戰(zhàn) CDA 數(shù)據(jù)分析師考試:需要多久?如何規(guī)劃? CDA(Certified Data Analyst)數(shù)據(jù)分析師認證作為國內(nèi)權(quán)威的數(shù)據(jù)分析能力認證 ...
2025-07-08LSTM 輸出不確定的成因、影響與應(yīng)對策略? 長短期記憶網(wǎng)絡(luò)(LSTM)作為循環(huán)神經(jīng)網(wǎng)絡(luò)(RNN)的一種變體,憑借獨特的門控機制,在 ...
2025-07-07統(tǒng)計學(xué)方法在市場調(diào)研數(shù)據(jù)中的深度應(yīng)用? 市場調(diào)研是企業(yè)洞察市場動態(tài)、了解消費者需求的重要途徑,而統(tǒng)計學(xué)方法則是市場調(diào)研數(shù) ...
2025-07-07CDA數(shù)據(jù)分析師證書考試全攻略? 在數(shù)字化浪潮席卷全球的當(dāng)下,數(shù)據(jù)已成為企業(yè)決策、行業(yè)發(fā)展的核心驅(qū)動力,數(shù)據(jù)分析師也因此成為 ...
2025-07-07剖析 CDA 數(shù)據(jù)分析師考試題型:解鎖高效備考與答題策略? CDA(Certified Data Analyst)數(shù)據(jù)分析師考試作為衡量數(shù)據(jù)專業(yè)能力的 ...
2025-07-04SQL Server 字符串截取轉(zhuǎn)日期:解鎖數(shù)據(jù)處理的關(guān)鍵技能? 在數(shù)據(jù)處理與分析工作中,數(shù)據(jù)格式的規(guī)范性是保證后續(xù)分析準確性的基礎(chǔ) ...
2025-07-04CDA 數(shù)據(jù)分析師視角:從數(shù)據(jù)迷霧中探尋商業(yè)真相? 在數(shù)字化浪潮席卷全球的今天,數(shù)據(jù)已成為企業(yè)決策的核心驅(qū)動力,CDA(Certifie ...
2025-07-04CDA 數(shù)據(jù)分析師:開啟數(shù)據(jù)職業(yè)發(fā)展新征程? ? 在數(shù)據(jù)成為核心生產(chǎn)要素的今天,數(shù)據(jù)分析師的職業(yè)價值愈發(fā)凸顯。CDA(Certified D ...
2025-07-03