Date: Tue, 9 Dec 2008 22:41:54 -0500
Reply-To: Sigurd Hermansen <HERMANS1@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Sigurd Hermansen <HERMANS1@WESTAT.COM>
Subject: Re: Creating a Exported javascript .js export file using parts of
a dataset
In-Reply-To: <af7d406c0812091422u2fa856bfwaa2457f5f74f25d3@mail.gmail.com>
Content-Type: text/plain; charset="us-ascii"
Long before Java or Javascript or anything else new under Sun, SAS created the FILE and PUT statements for the purpose of writing data into text or script files with extensions not limited to .js. Will this old technology help produce new technique? I think so.
S
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of sas 9 bi user
Sent: Tuesday, December 09, 2008 5:22 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Creating a Exported javascript .js export file using parts of a dataset
SAS friends,
I have some data in a dataset that I need to call in a html page. The data
I want to imbed is going to be javascript code in the html.
Suppose I have the following dataset:
DATA have;
input value $ 1-10;
datalines;
set(6,31)
set(9,13)
set(1,34)
set(8,43)
set(2,83)
set(3,33)
;
run;
I ultimately I want to have the above exported into a text file with a .js extension exactly as follows below. Note the number 6 and the set() values need to come from "have" as the values in the Value column . The number 6 would change based on the row count so it cant be hardcoded:
<SCRIPT LANGUAGE="JavaScript">
x = 6
set(6,31)
set(9,13)
set(1,34)
set(8,43)
set(2,83)
set(3,33)
if x < 7 then y = 10 else y = 1
</SCRIPT>
Does that make sense? I need no more or less than the above, exported from the dataset "have" with the number of rows to be dynamically inserted to my .js file and some standard javascript code that I provided above (eg the header and footer and my if statement).
I have tried doing a proc export as a .txt file but that adds the column name to the text file and I cant figure out how to add the number of records and the header, footer and my IF statement above using a PUT or anything like that and I cant figure out how to save it as a .js file. I rely on your wisdom for advice!!
Any thoughts would be greatly appreciated and I thank you in advance for any thoughts!
|