<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: push data to firebase in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/push-data-to-firebase/m-p/225523#M5404</link>
    <description>&lt;P&gt;This is working for me:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%let firebaseURL = https://YOURFIREBASEAPP.firebaseio.com/;
%let filePath = \\FILESERVER\BLA\BLA\BLA\;
%let jsonFile = MYDATA.json;

filename resp TEMP;
filename headout TEMP;
filename input "&amp;amp;filePath.&amp;amp;jsonFile";

proc http 
	method="PUT"
	url="&amp;amp;firebaseURL.&amp;amp;jsonFile"
	in=input
	out=resp
	headerout=headout
;run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(POST is also working but adds a random id to your data.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 15 Sep 2015 08:31:08 GMT</pubDate>
    <dc:creator>mathias</dc:creator>
    <dc:date>2015-09-15T08:31:08Z</dc:date>
    <item>
      <title>push data to firebase</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/push-data-to-firebase/m-p/225182#M5395</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Has anyone worked with firebase yet? (&lt;A href="http://www.firebase.com)" target="_blank"&gt;www.firebase.com)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to push data from an automated SAS egp&amp;nbsp;to firebase.&lt;/P&gt;&lt;P&gt;This will allow me to request it easily from a web app and set user permissions on it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.firebase.com/docs/rest/guide/saving-data.html" target="_blank"&gt;https://www.firebase.com/docs/rest/guide/saving-data.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Beause it's still new, I cannot find a single&amp;nbsp;article/post/question about this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EDIT: I have SAS 9.3 and I'm working in Enterprise Guide 5.1 on Windows7&lt;/P&gt;</description>
      <pubDate>Fri, 11 Sep 2015 16:05:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/push-data-to-firebase/m-p/225182#M5395</guid>
      <dc:creator>mathias</dc:creator>
      <dc:date>2015-09-11T16:05:01Z</dc:date>
    </item>
    <item>
      <title>Re: push data to firebase</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/push-data-to-firebase/m-p/225188#M5396</link>
      <description>&lt;P&gt;I have no experience with this. But since firebase supports a REST Interface you might be able to use &lt;A href="http://support.sas.com/documentation/cdl/en/proc/67916/HTML/default/viewer.htm#n197g47i7j66x9n15xi0gaha8ov6.htm" target="_self"&gt;Proc HTTP&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Sep 2015 15:22:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/push-data-to-firebase/m-p/225188#M5396</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2015-09-11T15:22:57Z</dc:date>
    </item>
    <item>
      <title>Re: push data to firebase</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/push-data-to-firebase/m-p/225192#M5397</link>
      <description>&lt;P&gt;Mathias,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would look into the following two Procedures in SAS 9.4&lt;/P&gt;&lt;P&gt;&amp;nbsp;- &lt;A title="JSON Procedure" href="http://support.sas.com/documentation/cdl/en/proc/67916/HTML/default/viewer.htm#p0ie4bw6967jg6n1iu629d40f0by.htm" target="_self"&gt;Proc JSON&lt;/A&gt;: To convert your SAS tables into JSON format&lt;/P&gt;&lt;P&gt;&amp;nbsp;- &lt;A title="Example 2: A Simple PUT Request " href="http://support.sas.com/documentation/cdl/en/proc/67916/HTML/default/viewer.htm#n0vfw4ml5fwn4un1ru90xy4s36oa.htm" target="_self"&gt;Proc HTTP&lt;/A&gt;: To connect to your Firebase database via Rest&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Good luck,&lt;/P&gt;&lt;P&gt;Ahmed&lt;/P&gt;</description>
      <pubDate>Fri, 11 Sep 2015 15:50:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/push-data-to-firebase/m-p/225192#M5397</guid>
      <dc:creator>AhmedAl_Attar</dc:creator>
      <dc:date>2015-09-11T15:50:47Z</dc:date>
    </item>
    <item>
      <title>Re: push data to firebase</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/push-data-to-firebase/m-p/225196#M5399</link>
      <description>&lt;P&gt;I forgot to say that&amp;nbsp;I'm working on SAS 9.3 and with Enterprise guide 5.1&lt;/P&gt;&lt;P&gt;I don't think I have proc json, but I already have created the&amp;nbsp;json file with a data step.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Sep 2015 16:30:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/push-data-to-firebase/m-p/225196#M5399</guid>
      <dc:creator>mathias</dc:creator>
      <dc:date>2015-09-11T16:30:48Z</dc:date>
    </item>
    <item>
      <title>Re: push data to firebase</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/push-data-to-firebase/m-p/225260#M5402</link>
      <description>&lt;P&gt;It worked!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'll post the code here when I'm back at work Tuesday.&lt;/P&gt;</description>
      <pubDate>Sat, 12 Sep 2015 10:04:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/push-data-to-firebase/m-p/225260#M5402</guid>
      <dc:creator>mathias</dc:creator>
      <dc:date>2015-09-12T10:04:14Z</dc:date>
    </item>
    <item>
      <title>Re: push data to firebase</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/push-data-to-firebase/m-p/225523#M5404</link>
      <description>&lt;P&gt;This is working for me:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%let firebaseURL = https://YOURFIREBASEAPP.firebaseio.com/;
%let filePath = \\FILESERVER\BLA\BLA\BLA\;
%let jsonFile = MYDATA.json;

filename resp TEMP;
filename headout TEMP;
filename input "&amp;amp;filePath.&amp;amp;jsonFile";

proc http 
	method="PUT"
	url="&amp;amp;firebaseURL.&amp;amp;jsonFile"
	in=input
	out=resp
	headerout=headout
;run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(POST is also working but adds a random id to your data.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Sep 2015 08:31:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/push-data-to-firebase/m-p/225523#M5404</guid>
      <dc:creator>mathias</dc:creator>
      <dc:date>2015-09-15T08:31:08Z</dc:date>
    </item>
    <item>
      <title>Re: push data to firebase</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/push-data-to-firebase/m-p/225632#M5405</link>
      <description>&lt;P&gt;I created a JAVA adapter for Firebase.&amp;nbsp; Check it out!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/FriedEgg/firebase4sas" target="_blank"&gt;https://github.com/FriedEgg/firebase4sas&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;filename fbase "/path/to/firebase-client-jvm-2.3.1.jar"; /*https://cdn.firebase.com/java/firebase-client-android-2.3.1.jar*/
filename fb4sas "/path/to/firebase4sas.jar"; /*https://github.com/FriedEgg/firebase4sas/releases*/

/* create a file reference for the classes we are going to compile below with PROC GROOVY*/
filename cp temp;
proc groovy classpath=cp;

   /* add the two dependent libraries*/
   add classpath=fbase;
   add classpath=fb4sas;

   /* create a Model for the objects we are going to load. */
   submit load;
      public class Person {
         private String sex;
         private double age;
         private double height;
         private double weight;

         public Person(String sex, double age, double height, double weight) {
            this.sex    = sex;
            this.age    = age;
            this.height = height;
            this.weight = weight;
         }

         public String getSex() {
            return sex;
         }

         public double getAge() {
            return age;
         }

         public double getHeight() {
            return height;
         }

         public double getWeight() {
            return weight;
         }

         public String toString() {
            return "Person: Sex=" + sex + ", Age=" + age + ", Height" + height + ", Weight" + weight;
         }
      }
   endsubmit;

   /* create a class from the abstract to perform the load of our model */
   submit load;
      import java.lang.InterruptedException;

      public class PersonLoader extends AbstractFirebase4Sas {
         public PersonLoader(String firebase, String dsn, String name, String sex, double age, double height, double weight) {
            setFirebase(firebase);

            Person p = new Person(sex, age, height, weight);
            setLoaderObject(p);

            addChild(dsn);
            addChild(name);

            try {
               loadObject();
            } catch (InterruptedException e) {
               e.printStackTrace();
            }
         }
      }
   endsubmit;

   /* you can test it in PROC GROOVY */
   /*
   submit;
      lp = new LoadPerson("MYFIREBASE", "class", "Frog", "F", 14.1, 15.1, 16.1);
   endsubmit;
   */

quit;

/* add compiled classes from PROC GROOVY to session CLASSPATH */
options set=classpath "%sysfunc(pathname(cp,f))";

/* use data step JavaObject Component to load our data set to Firebase */
data _null_;
   set sashelp.class indsname=dsn;

   declare javaObj lp;
   lp = _new_ javaObj ("LoadPerson","MYFIREBASE",scan(dsn,2,'.'),name,sex,age,height,weight);

   lp.flushJavaOutput();
   lp.delete();

run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can create you own model and loader classes simply enough to load any table.&amp;nbsp; It should work with SAS 9.3+&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Sep 2015 15:49:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/push-data-to-firebase/m-p/225632#M5405</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2015-09-15T15:49:39Z</dc:date>
    </item>
    <item>
      <title>Re: push data to firebase</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/push-data-to-firebase/m-p/227701#M5513</link>
      <description>&lt;P&gt;I've made a macro that takes a sas dataset and writes it to firebase with parametrable variable names&lt;/P&gt;
&lt;P&gt;&lt;A title="gist" href="https://gist.github.com/mathiasleroy/f22face83d696b45c17a" target="_self"&gt;https://gist.github.com/mathiasleroy/f22face83d696b45c17a&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%macro pushFirebase(dataset,firebaseName,fbObject,variables);
/*
	! change temporaryFilePath to fit your environement

	dataset 	= sas data set to push to firebase
	firebaseName= name of your firebase app name (xxx.firebaseio.com)
	fbObject  	= name of the firebase object to create
	variables 	= list of variables to include, separated by dashes -
*/


	/* CONSTANTS */
	%let temporaryFilePath = \\sas9xbi\Data2\tmp\;

	/* VARIABLES */
	%let firebaseURL = https://&amp;amp;firebaseName..firebaseio.com/;
	%let fileName = &amp;amp;fbObject..json;
	%let variablesLength =  %sysfunc(count(&amp;amp;variables,-));

	
	/********************************************************************
		CREATE JSON OBJECT
	********************************************************************/

	data _null_;
		set &amp;amp;dataset nobs=nobs end=end;
		file "&amp;amp;temporaryFilePath.&amp;amp;fileName";

		if _n_=1 then put '{';
		
			put '"' %scan(&amp;amp;variables,1,-) +(-1) '":{';

				%do i = 1 %to &amp;amp;variablesLength+1;
					variable = %sysfunc(strip("%scan(&amp;amp;variables,&amp;amp;i,-)"));
					*this is a repetition, but it makes json cleaner;
					if (&amp;amp;i ne 1) then put ',"' variable +(-1) '":' %scan(&amp;amp;variables,&amp;amp;i,-) ;
					else put '"' variable +(-1) '":' %scan(&amp;amp;variables,&amp;amp;i,-) ;
				%end;
			put '}';

			if not end then do;
				put ',';
				end;

		if end then do;
			put '}';
			end;
		run;



	/********************************************************************
		PUSH TO FIREBASE 
	********************************************************************/

	filename resp TEMP;
	filename headout TEMP;
	filename input "&amp;amp;temporaryFilePath.&amp;amp;fileName";

	proc http 
		method="PUT"
		url="&amp;amp;firebaseURL.&amp;amp;fileName"
		in=input
		out=resp
		headerout=headout
		;run;

%mend;

%pushFirebase(xxx.xxx,xxx,xxx,xxx-xxx-xxx-xxx);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2015 15:57:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/push-data-to-firebase/m-p/227701#M5513</guid>
      <dc:creator>mathias</dc:creator>
      <dc:date>2015-09-29T15:57:12Z</dc:date>
    </item>
  </channel>
</rss>

