Solution 1:
%MACRO Get_data(myDataset=,myLine=,myColumn=,myMVar=);
%GLOBAL &myMVar.;
data _null_;
set &myDataset.;
if _N_ = &myLine. then do;
call symput(symget('myMVar'),&myColumn.);
end;
run;
%MEND Get_data;
Solution 2:
%MACRO Get_data(myDataset=,myLine=,myColumn=,myMVar=);
%GLOBAL &myMVar;
proc sql noprint;
select &myColumn into :&myMVarfrom &myDatasetwhere monotonic() = &myLine;
quit;
%MEND Get_data;
%Get_data(myDataset=tablename,myLine=linenumber,myColumn=colname,myMVar=varname)
%put &varname;
Solution 3: USE SAS I/O functions!
%MACRO Get_data(myDataset,myLine,myColumn);
%global myMvar;
%let dsid=%sysfunc(open(&myDataset.,i));
%let rc=%sysfunc(fetchobs(&dsid, &myLine.));
%if &rc = 0 %then
%let myMvar=%sysfunc(GETVARN(&dsid,%sysfunc(varnum(&dsid,&myColumn))));
/****use getvarc for character variables*****/
%let rc=%sysfunc(close(&dsid));
%MEND Get_data;
MORE SAS CODES
http://www.datasavantconsulting.com/roland/Spectre/maclist2.html
Monday, June 6, 2011
Friday, June 3, 2011
Route SAS log and procedure ouput using PROC PRINTTO
PROC PRINTTO is very useful when we try to automate the debugging process of SAS program.
LABEL= provide a description for a SAS log or procedure output stored in a SAS catalog entry
LOG= route the SAS log to a permanent external file or SAS catalog entry
LOG= and PRINT= with same destination combine the SAS log and procedure output into a single file
NEW= replace the file instead of appending to it
PRINT= route procedure output to a permanent external file or SAS catalog entry
Using a PROC PRINTTO statement with no options closes any files opened by a PROC PRINTTO statement points both the SAS log and SAS procedure output to their default destinations.
Example:
options nodate pageno=1 linesize=80 pagesize=60 source;
proc printto log='log-file';
run;
data numbers;
input x y z;
datalines;
14.2 25.2 96.8
10.8 51.6 96.8
9.5 34.2 138.2
8.8 27.6 83.2
11.5 49.4 287.0
6.3 42.0 170.7
;
proc printto print='output-file' new;
run;proc print data=numbers;
title 'Listing of NUMBERS Data Set';
run;
proc printto;
run;
LABEL= provide a description for a SAS log or procedure output stored in a SAS catalog entry
LOG= route the SAS log to a permanent external file or SAS catalog entry
LOG= and PRINT= with same destination combine the SAS log and procedure output into a single file
NEW= replace the file instead of appending to it
PRINT= route procedure output to a permanent external file or SAS catalog entry
Using a PROC PRINTTO statement with no options closes any files opened by a PROC PRINTTO statement points both the SAS log and SAS procedure output to their default destinations.
Example:
options nodate pageno=1 linesize=80 pagesize=60 source;
proc printto log='log-file';
run;
data numbers;
input x y z;
datalines;
14.2 25.2 96.8
10.8 51.6 96.8
9.5 34.2 138.2
8.8 27.6 83.2
11.5 49.4 287.0
6.3 42.0 170.7
;
proc printto print='output-file' new;
run;proc print data=numbers;
title 'Listing of NUMBERS Data Set';
run;
proc printto;
run;
Wednesday, June 1, 2011
Second day at work!
I am so bored right now.
I still don't have access to mainframe SAS, so I can't look at codes and try out things. More important, I listened to people talking about their works, and unfortunately realized that this is not an exciting job as I had before.
When you trade, even you are not well paid, it's still exciting. But when you look at others' trading numbers, it's certainly like a whole world apart. Besides these, this job is such a long hour job, that it hardly justify the salary. OK, I admit that most people don't earn as much as I did. I was spoiled. But I feel I deserve better. Who cares what I think!
The bright spot of this job is the company title comes with it. Is this all about? Why I am here?
My manager have spent 1 hour persuading her underling to work on July 4th, now I feel sorry for her.
I hope my son Sam had a wonderful day.
I still don't have access to mainframe SAS, so I can't look at codes and try out things. More important, I listened to people talking about their works, and unfortunately realized that this is not an exciting job as I had before.
When you trade, even you are not well paid, it's still exciting. But when you look at others' trading numbers, it's certainly like a whole world apart. Besides these, this job is such a long hour job, that it hardly justify the salary. OK, I admit that most people don't earn as much as I did. I was spoiled. But I feel I deserve better. Who cares what I think!
The bright spot of this job is the company title comes with it. Is this all about? Why I am here?
My manager have spent 1 hour persuading her underling to work on July 4th, now I feel sorry for her.
I hope my son Sam had a wonderful day.
Subscribe to:
Posts (Atom)