BookmarkSubscribeRSS Feed
Hagay
SAS Employee

המידע שאנחנו מעבדים ב – SAS מגיע ממקורות רבים, חלקו מקבצים שטוחים כגון CSV, DAT וחבריהם, חלקו מבסיסי נתונים והיתר ממגוון רחב של מקורות שונים ביניהם מקור נתונים שהולך ותופס חלק גדול יותר ויותר בשנים האחרונות - האינטרנט.

 

גופים רבים מאפשרים לנו גישה (חלקם באופן חופשי וחלקם לא) למגוון רחב של נתונים דרך האתרים שלהם באינטרנט. וחברת SAS דאגה לכך שנוכל לעבוד עם נתונים גם ממקור זה כחלק מתוכניות ה – SAS שלנו.

 

אחראי מרכזי על הקסם הזה ב -SAS  הוא PROC HTTP שמאפשר לנו לבצע אינטראקציות עם אתרי אינטרנט בדומה לדפדפן ובכך לשלב בקוד ישירות שלנו מגוון פתרונות לגישה לנתונים שיושבים באינטרנט ללא מגע יד אדם.

 

לשם הדוגמא נשתמש באתר השירות המטאורולוגי של ישראל שמאפשר דרך האתר שלו גישה למספר נתונים, ביניהם מגוון מדדי מזג אויר בתחנות המדידה בארץ:

filename httpout temp;

proc http 
	method="GET" /*getting information by accessing a web address*/
	url="https://ims.data.gov.il/sites/default/files/xml/imslasthour.xml" /*the web address of the file we want to download*/
	out=httpout /*the data we will download will be saved to this filename*/;
run;


* Processing the data we have just got; libname httpout xml; * Reading the downloaded data using the XML engine; data WEATHER_NAMES; set httpout.Hebrewvariablesnames; run; data WEATHER_OBS; set httpout.observation; run; * Just having some fun - adding the full columns descriptions in Hebrew as labels; proc transpose data=WEATHER_NAMES out=WEATHER_NAMES_T(drop=_label_ rename=(_name_=Column_NM col1=Column_Hebrew_NM)); var _all_; run; filename sascode temp; data _null_; set WEATHER_NAMES_T end=last; file sascode; if _n_=1 then do; put "proc datasets nolist lib=work;"; put "modify WEATHER_OBS;"; end; put "attrib " column_nm "label='" column_hebrew_nm +(-1) "';"; if last then do; put "run;"; put "quit;"; end; run; %include sascode; * Clean up; filename sascode clear; filename httpout clear;

חגי

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Discussion stats
  • 0 replies
  • 289 views
  • 0 likes
  • 1 in conversation