Wondering if anyone can please point me in the right direction here. I'm trying to pass a character value from one dataset to another, so I'm trying to use CALL SYMPUT. Let's say my variable name is ID and my values are in the format 999.XXX.999
My data step is as follows:
CALL SYMPUT ('PASS_ID',ID);
But then when I try to assign this to a variable in another dataset as follows:
NEWID = &PASS_ID;
SAS very politely tells me that it's expecting a numeric operator. I thought maybe the periods were messing things up, but when I remove them, I still get an error. So then I thought maybe it's because I'm starting with a number, but when I start with a character, it creates a new variable the name of which is the value.
The process works great if the value is numeric, but I can't seem to get it to work with my string. Any thoughts please?
It's a fact that you are only going to pass the "last observation's value". Explain why you feel compelled to use SAS macro variable to do work that typically occurs with other SAS facilities, especially without considering how/when macro variables are resolved (during compilation)?
Suggest you back-up and explain what you are attempting to accomplish with this task and divorce the verbiage from the SAS programming language altogether.
Thanks for posting back Scott. Yes, I know that this only returns the "last observation value"; I actually have this in a loop, so it actually passes multiple values from each record of a dataset, one record at a time, to a series of other steps.
I'm trying to grab a string from one record in a dataset, and assign it to a pseudo-randomly selected record in another dataset, based on a series of rules and probability distributions. It's part of a bigger simulation algorithm I'm trying to get to work.
I don't feel compelled to use a SAS macro variable if there are other options, though I don't know what those would be (to iteratively pass the value from one dataset to another - without getting into more complex syntax like sysfunc and getvarc) - so if there's something else, let me know.
I'm well aware of how/when macro variables are resolved, and they resolve fine in my syntax.
Then, I suggest in the future that you not post bogus code that doesn't apply to what it is that you are trying to accomplish - what that does is waste others' time in the process. If you are using some type of DO / END loop to do whatever (with assigning multiple, unique macro variables, and then I suppose you are using SYMGET to retrieve them and are doing some type of INPUT function to convert back to a numeric, then post that code for meaningful application and feedback from forum subscribers.
My suggestion is that you consider reading your file WORK.COUPLESET2 into a second DATA step, capturing some quantity of SAS variable values using DO UNTIL (EOF1) / SET.... END=EOF1 / END, followed by another DO UNTIL(EOF2) / SET .... END=EOF2 / END and make use of your SAS variables with assignment statements.
Without seeing value length ranges for your COUPLESET2 file which you mentioned about passing using macro variables, if you intend to go the macro var route, you will want to look at declaring with a LENGTH or ATTRIB statement the variable(s) that you are passing.
Thanks again Scott....though I'm clearly not explaining myself very well. Thank you for your suggestion, but it doesn't actually solve my issue. Thanks for trying though....I'll keep plugging away at it.
My point is that you need to share exactly what code is not working for you, since it is not that code you supplied in your original post. And provide it in the form of a pasted SAS-generated log with all code revealed and any additional diagnostic output needed (PUTLOG command(s), PROC CONTENTS, other displays) to accurately explain your problem.
Message was edited by: sbb
you can use this function symget
run;maybe this message will help you