BookmarkSubscribeRSS Feed
deleted_user
Not applicable
The problem goes like this:
I want to read the values of a variable in a table in SQL Database and each of this value should be given as an input to a SAS Macro which generate sas dataset according to the values given to the Macros, e.g., like if AE is the first value of the table, it should b read from database and give as the input to the Macro. This should b run for every value of the column in the database table.
I use the following code:

%let tbl=;
%macro DATASET;
%let n=1;
%do n %to &ds;
proc sql noprint;
select datasetname format=$10. into :tbl
from datalib.ds_attributes
order by datasetname;
%readtbl(tbl=&tbl);
quit;
%end;
%put &tbl;
%mend DATASET;
%dataset;

I am sure v can do this by assign any do loop function, but It reads only the first value of the variable and runs as many times as &DS, ultimately brings out an error.
Let me know if any solutions.
3 REPLIES 3
deleted_user
Not applicable
see a solution for invoking a macro multiple times from a data set, in a parallel forum at
http://support.sas.com/forums/thread.jspa?threadID=2294&tstart=0

The only difference is that your data set uses a library engine pointing into an SQL database

PeterC
deleted_user
Not applicable
Thanks that worked. It was really helpful.
deleted_user
Not applicable
The above solution did worked out, but whenever it find out any error, the set option is set to obs=0. Therefore, no records are read or processed & whatever datasets are created has 0 records...
the error I get is as follows:

MPRINT(READTBL): *PRIYA: SORTING DATASETS;
SYMBOLGEN: Macro variable TBL resolves to LAB
MPRINT(READTBL): PROC SORT DATA = DATA0047.LAB;
MPRINT(READTBL): BY PATID VISIT SEQNUM ;
ERROR: Variable SENUM not found.
ERROR: Variable SENUM not found.
ERROR: Variable SENUM not found.
MPRINT(READTBL): RUN;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: SAS set option OBS=0 and will continue to check statements.
This may cause NOTE: No observations in data set.
NOTE: PROCEDURE SORT used:
real time 0.03 seconds
cpu time 0.00 seconds


Can someone help me to reslove this issue.
Thanks
Priya

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Health and Life Sciences Learning

 

Need courses to help you with SAS Life Sciences Analytics Framework, SAS Health Cohort Builder, or other topics? Check out the Health and Life Sciences learning path for all of the offerings.

LEARN MORE

Discussion stats
  • 3 replies
  • 1154 views
  • 0 likes
  • 1 in conversation