08-26-2014 12:12 PM
I'm looking for a way to parsing a query string and storing values during data step.
So i don't know the number of query parameters, and the set of query parameters used can be different. I'm thinking that I'll need to use an array and some macro but wondering if anyone has an easy way to do this and can give me some better ideas. Thanks! John
count = countc(queryString_2,'&');
/*PARSE QUERY STING INTO AN ARRAY*/
/*WALK THROUGH THE QUERY STRING AND ASSIGN THE VALUE OF THE QUERY PARAMETER TO THE APPROPRIATE TABLE VARIABLE*/
do while i<count;
08-26-2014 01:43 PM
I'm not quite sure what you expect but I think you might write that data out to a text file and then read it using NAMED input with a delimiter of &.
Though if your values have imbedded spaces this may not work but could be doable making sure there are two spaces before each variable name (i.e. replace the & with two spaces.
You really should provide at least a couple of lines of data for use to look at.
08-27-2014 11:25 AM
Thank you. Here is an example of the data that we get. We can retrieve it from the server its stored on, but we are limited right now in our ability to re-write the data into a text file. We're exploring SAS as a option for parsing it into meaningful pieces. There is other data in the file, but we are only interested in cs-uri-stem
08-27-2014 01:20 PM
Better off storing this as name/value pairs.
input querystring & $100. ;
data want ;
* assign QUERYSTRING to NEXT to force SAS to define the length ;
do i=1 by 1 until (next=' ');
name = scan(next,1,'=');
value = substr(next,length(name)+2);
if name ne ' ' then output;