LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (February 2008, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 25 Feb 2008 10:14:02 -0800
Reply-To:     NMani <naveen.manivannan@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         NMani <naveen.manivannan@GMAIL.COM>
Organization: http://groups.google.com
Subject:      Passing variables from data step to macro while avoiding loops.
              Is it possible?
Comments: To: sas-l@uga.edu
Content-Type: text/plain; charset=ISO-8859-1

Dear SAS Experts;

(1) I'm very confused. I thought I could exploit the data step to avoid creating a program that doesn't need loops but I'm having trouble understanding how to pass variable from the data step to the macro within the data step itself. If I take the macro outside the data step, the program will work but only for the 20th symbol the "test1" dataset. I think the problem might be that the PDV initializes null and that's messing up the program. I don't really know though. Can someone offer me an idea on what's happening in the background and/ or any suggestions on making this program work.

(2) If my program runs into a symbol and returns an error message(usually if the symbol cannot be found on yahoo's database) then it stops. For those Visual Basic programmers there's a line of code, "One Error Resume Next" that forces the program to continue even if an error is generated. Is there a SAS equivalent?

Sincerely,

A student preparing for his base sas certification

---------------------------------------------------------------------------------------------------------------- CODE:

data blah; *Random name, should be _null_ but keeping it blah for testing reasons;

set test1(obs=20); *Contains the dataset with the ticker names under the variable name "symbol";

call symput("stk", put(symbol, $10.)); *Creates the global variable "stk" with whatever is in the PDV for symbol. I think???;

%quotes (symbol=&stk, start=11/1/45, end = 11/1/09); *Macro that created a separate datasets based on the argument supplied for "symbol=";

run;

LOG: 127 data blah; 128 set test1(obs=20); 129 130 call symput("stk", put(symbol, $10.)); 131 %quotes (symbol=&stk, start=11/1/45, end = 11/1/09); WARNING: Apparent symbolic reference STK not resolved. WARNING: Apparent symbolic reference STK not resolved. WARNING: Apparent symbolic reference STK not resolved. WARNING: Apparent symbolic reference STK not resolved. WARNING: Apparent symbolic reference STK not resolved. WARNING: Apparent symbolic reference STK not resolved. WARNING: Apparent symbolic reference STK not resolved. WARNING: Apparent symbolic reference STK not resolved. WARNING: Apparent symbolic reference STK not resolved. WARNING: Apparent symbolic reference STK not resolved. WARNING: Apparent symbolic reference STK not resolved. http://table.finance.yahoo.com:80/table.csv?s=&STK&a=10&b=1&c=1945&d=10&e=1&f=2009&g=d WARNING: Apparent symbolic reference STK not resolved. WARNING: Apparent symbolic reference STK not resolved.

NOTE: There were 20 observations read from the data set WORK.TEST1. NOTE: The data set WORK.BLAH has 20 observations and 5 variables. NOTE: DATA statement used (Total process time): real time 0.05 seconds cpu time 0.03 seconds

NOTE: Line generated by the macro variable "SYMBOL". 1 &STK - 22 --- 202

ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, /, ;, _DATA_, _LAST_, _NULL_.

ERROR 202-322: The option or parameter is not recognized and will be ignored.

NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set WORK.STK may be incomplete. When this step was stopped there were 0 observations and 7 variables. NOTE: DATA statement used (Total process time): real time 0.02 seconds cpu time 0.03 seconds

132 run;


Back to: Top of message | Previous page | Main SAS-L page