I am using this code (simplified) in a macro:
PROC TRANSPOSE data=Temp out=TransTemp (drop=_:);
by Range;
var SomeVar;
id Segment;
run;
proc print data=TransTemp NOOBS;
var Range
x
y
z
;
format
x
y
z NLMNLGBP.
;
run;
Unfortunately I sometimes only have a subset of the above columns (x, y, z) present in TransTemp. Is there anything I can do to adjust the code to dynamically adapt - i.e. macrotise it somehow?
Try this format statement:
format _numeric_ NLMNLGBP. range;
You may not need to add RANGE to the list, if it is character. This statement assigns the format to all numeric variables being printed, but then removes any format assigned to RANGE.
not sure if I understood your question
1. do you want to list all your variable names in your transtemp dataset
2. is the problem to do with listing fewer variale names in var statement when there are fewer vars in transtemp?
Thanks for the reply. Yes 2 is the problem ...
Well, i suppose you can do away with your var statement
data w;
set sashelp.class;
run;
proc print data=w noobs;
run;
and let sas list the N number of vars in the input dataset by default without you having to mention it.
Or am i missing something here?
Sorry no I cannot (I think) as I want to format them. I am using:
format
x
y
z percent7.1
;
or
proc format;
value Bla
low -< -1.0 = "red"
-1 -< 0 = "green"
0 - high = "white";
run;
...
/style(data) = [background=Bla.]
in my proc print statement.
You can use proc format and define all formats you need independenly from variables you want to use.
Assuming you want to print part of the variables in the dataset you can use KEEP statement, to keep wanted variables,
in the PROC PRINT procedure.
You can define the variables using %LET staement preceding the proc print:
%let vars = x y; /* list of wanted variables */
proc print data=w(keep=&vars) noobs;
run;
In case you want to print all varaibles, you can assign vars to _ALL_;
Try this format statement:
format _numeric_ NLMNLGBP. range;
You may not need to add RANGE to the list, if it is character. This statement assigns the format to all numeric variables being printed, but then removes any format assigned to RANGE.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.