What about the relationship between them?
In my opinion, INPUT function is the inverse process of PUT function.
PUT function: convert the variable value to a character string
INPUT function: convert a character string to the variable value
Monday, September 7, 2009
Thursday, September 3, 2009
Macro variable in PROC SQL
There are two ways to store values of column in PROC SQL.
1. mv with separator, which store values of the rows into one mv
2. mv range, which store value of one row per mv
1. mv with separator, which store values of the rows into one mv
2. mv range, which store value of one row per mv
* Sample code;
proc sql;
select distinct sex, name
into:sex seperated by ' ', :name1-:name100
from sashelp.class;
%let num = &sqlobs;
quit;
%put Number: &sqlobs;
%put _global_;
Thursday, August 20, 2009
Short for style expression
With the power of ODS, we can specify the style elements for specific location, especially for reporting procedure like PROC PRINT, PROC REPORT, PROC TABULATE.
If the style expression is trivial and long, it will be boring to apply same style expression to many reports at one time.
For example:
To avoid typing the same expression again and again, we can customize style using PROC TEMPLATE.
The report above can be converted to:
If the style expression is trivial and long, it will be boring to apply same style expression to many reports at one time.
For example:
ods html file="style.html";
proc report data=sashelp.class nowd;
column name age;
define name/display
style(header)=[just=l
foreground=red
cellwidth=2cm];
define age / display ;
run;
ods html close;
To avoid typing the same expression again and again, we can customize style using PROC TEMPLATE.
The report above can be converted to:
proc template;
define style styles.mystyle;
parent=default;
style header1 from header /
foreground=red
width=2cm
textalign=left;
end;
run;
ods html file="style2.html" style=mystyle;
proc report data=sashelp.class nowd;
column name age;
define name / style(header) = header1;
define age / display ;
run;
ods html close;
Tuesday, August 18, 2009
Are you missing "missing option"?
Generally, SAS do not take missing value as a valid value, especially for class variable. That means there will be an implicit filter to delete all "missing" class, e.g. the class variable in Proc MEANS, PROC FREQ.
Likewise, missing values is not valid value for any group, order or across variable in Proc REPORT.
Likewise, missing values is not valid value for any group, order or across variable in Proc REPORT.
Tuesday, August 11, 2009
What ODS templates are in use?
Generally, procedure output will use table template and style template.
Below are the methods to identify them:
#1:
ODS TRACE statement can print what table template is in use.
#2:
Default style information is in SAS registry.
command "regedit" -> ODS -> DESTINATION -> "Selected Style" entry in specified destination
Below are the methods to identify them:
#1:
ODS TRACE statement can print what table template is in use.
#2:
Default style information is in SAS registry.
command "regedit" -> ODS -> DESTINATION -> "Selected Style" entry in specified destination
Thursday, July 9, 2009
Close many VIEWTABLES at one time
In SAS DMS, I always view the dataset using Viewtable.
It is boring to close many viewtables before rerun the pgm.
I ever asked for help on comp.soft-sys.sas newsgroup. However, I am not satisfied with the answers.
Today, an idea rushed my mind. I have tried and believe it is a wonderful tip. :)
Here are the steps:
1. Define command style macro %closevts and save as closevts.sas
2. Update configuration file
-cmdmac
-set sasautos (
.......
macro-%closevts-path
)
3. Issue %closevts in command line
It is boring to close many viewtables before rerun the pgm.
I ever asked for help on comp.soft-sys.sas newsgroup. However, I am not satisfied with the answers.
Today, an idea rushed my mind. I have tried and believe it is a wonderful tip. :)
Here are the steps:
1. Define command style macro %closevts and save as closevts.sas
%macro closevts / cmd;
%local i;
%do i=1 %to 20;
next "viewtable:";end;
%end;
%mend;
2. Update configuration file
-cmdmac
-set sasautos (
.......
macro-%closevts-path
)
3. Issue %closevts in command line
Wednesday, July 1, 2009
%LOCAL secrete
When programming, we always put the %LOCAL and %GLOBAL statement at the top of macro definition.
Why?
In this way, we can guarant that same LOCAL/GLOBAL mv is always in effect in macro execution. If %LOCAL is in the middle, the global mv is probably in use.
Why?
In this way, we can guarant that same LOCAL/GLOBAL mv is always in effect in macro execution. If %LOCAL is in the middle, the global mv is probably in use.
*%LOCAL secrete sample;
%let test = global;
%macro test();
%put Before %nrstr(%local): "&test";
%local test;
%put After %nrstr(%local): "&test";
%mend;
%test()
Subscribe to:
Posts (Atom)