Recent Activity
How do I count all the non missing observations of a bunch of categorical variables then present these counts on a bar chart? I have tried proc freq, output to a data set then use proc means sum option. This is very time consuming because I need to do that to like 10 variables and I am sure there’s a smarter way to do this Also need to compare the counts Thank you!!
... View more

0
0
SAS Viya Monitoring for Kubernetes has introduced two features in version 1.2.36 (15th April 2025) aimed at simplifying deployment; auto-generating Ingress definitions and automatically specifying storage class references. These enhancements reduce the need for manual configuration, making setup easier and more efficient.
How Ingress is Used in SAS Viya Monitoring
Ingress resources in Kubernetes manage external access to services within the cluster, typically HTTP and HTTPS traffic. In SAS Viya Monitoring, Ingress facilitates access to web-based monitoring tools like Grafana and OpenSearch Dashboards (OSD). Properly configured Ingress ensures that users can securely and efficiently interact with these interfaces.
... View more

- Find more articles tagged with:
- deployment
- grafana
- ingress
- monitoring
- observability
- Opensearch
- prometheus
0
0
Dear All I wanted to run Monte Carlo Simulation - Run 10 Iterations but dont know that why its giving me the same out for all 10 itertaions (output attached). I have used chatgpt & deepseek but its of no support. I have attached dataset as well as sas coding script. Would appreciate support by pasting code completely or answering me after checking 1st that its working in sas on demand. Thank you /* Step 4: Monte Carlo Simulation - Run 10 Iterations for Random Loss Outcomes */ data montecarlo; set portfolio_sim; do sim_id = 1 to 10; /* Introduce random variation to PD and LGD */ random_PD = rand("NORMAL", Sim_PD, 0.01); random_LGD = rand("NORMAL", Sim_LGD, 0.05); random_PD = max(0, min(random_PD, 1)); random_LGD = max(0, min(random_LGD, 1)); sim_loss = random_PD * random_LGD * EAD * Current_Balance; output; end; run; OR data montecarlo; set portfolio_sim; /* Convert alphanumeric Borrower_ID to numeric seed */ numeric_id = input(compress(Borrower_ID, , 'kd'), 8.); do sim_id = 1 to 10; /* Create unique seed for each borrower-simulation combination */ seed = numeric_id * 100 + sim_id; call streaminit(seed); /* Generate random values */ random_PD = rand("NORMAL", Sim_PD, 0.01); random_LGD = rand("NORMAL", Sim_LGD, 0.05); /* Constrain to valid ranges */ random_PD = max(0, min(random_PD, 1)); random_LGD = max(0, min(random_LGD, 1)); /* Calculate loss */ sim_loss = random_PD * random_LGD * EAD * Current_Balance; output; end; drop numeric_id seed; /* Clean up temporary variables */ run;
... View more

0
14
Consider the requirement to convert numeric variables to same named character variables, and the character values must be the formatted numeric values, and the original column order must be maintained. More generally, conversion is rendering process.
My first cut is
%macro num_to_char(data=) ;
%local vars renames reassigns drops formats;
proc contents noprint data=&data out=n2c_contents ; run ;
proc sql noprint ;
select trim(name)||'$'||cats(ifn(type=1,32,length))
into :vars separated by ' ' from n2c_contents order by varnum ;
select cats(name,'=_',varnum), cats(name,'=left(vvalue(_',varnum,'))'), cats('_',varnum)
, cats('_',varnum)||' '||ifc(format='','best32.',cats(format,formatl,'.',formatd))
into :renames separated by ' ', :reassigns separated by ';', :drops separated by ' '
, :formats separated by ' '
from n2c_contents where type = 1 ;
drop table n2c_contents ;
quit ;
%if %length(&renames) %then %do ;
data &data ;
length &vars ;
set &data (rename=(&renames)) ;
format &formats ;
&reassigns ;
drop &drops ;
run ;
%end ;
%mend num_to_char;
If this macro is for a general library, how much harder should it go?
The current implementation has all converted values being stored in a character variable of length $32 (call this the target/container/destination).
Which, if any, of these would be worth pursuing?
Make the target length match the numeric format length
Use format default length in dictionary.formats if not in data set metadata
Shortening the target length to only necessary length (max rendered length)
For example: binary numeric variables 0/1 do not need $32 when converted
With shortened target lengths want to avoid asteriks and truncated results
... View more

0
5
I am Learning the proc template. I tried to create a box plot with sashelp.cars. I've got to make it 80% of what I am thinking , I am stuck at the last 20 % to finish. Looking for help. My code creates graph correctly but stuck at creating the legend. Present graph only show the group legends text in legends, but 1. I want to add the number of to the legends text to display the counts. like (SUV-Asia (N= 25)). I tried creating the macro variable for counts and attach to the group., but it messing up my graph. 2. Is it possible to to diplay all the Asia related in one column, USA in another column, and Europe in another columns in Legends Here is my cars code *create data;
proc sql;
create table car_subjects as
select distinct
cats(Make, "-", Model) as USUBJID length=50,
Type as CarType length=15,
Origin as Region length=15,
Horsepower,
Weight,
MPG_City,
MPG_Highway,
MSRP
from sashelp.cars
where Make is not null and Model is not null;
quit;
*get Count to display in legend;
proc sql;
create table car_counts as
select CarType, Region, count(*) as N
from car_subjects
group by CarType, Region;
quit;
* Add count to dataset;
proc sort data=car_subjects;
by CarType Region;
run;
proc sort data=car_counts;
by CarType Region;
run;
/* Step 4: Merge and build final dummy dataset */
*try with few groups first;
data dummy_cars_final ( where = (region in ('USA' 'Asia' 'Europe') and cartype in ('SUV' 'Sedan' 'Truck')));
merge car_subjects(in=a) car_counts;
by CarType Region;
if a;
/* Derived variables */
region_type = catx("-", CarType, Region);
Score = round(40 + ranuni(0)*60, 0.1);
PowerIndex = round((Horsepower * 0.6 + Weight * 0.0005), 0.1);
EcoScore = round((MPG_City * 0.4 + MPG_Highway * 0.6), 0.1);
length LuxuryLevel $10;
if MSRP > 50000 then LuxuryLevel = "High";
else if MSRP > 30000 then LuxuryLevel = "Medium";
else LuxuryLevel = "Low";
drop Horsepower Weight MPG_City MPG_Highway MSRP;
run;
proc template;
define statgraph boxplot_template;
begingraph;
discreteattrmap name="comboMap" / ignorecase=true;
value "SUV-Asia" / fillattrs=(color=orange);
value "SUV-Europe" / fillattrs=(color=orange) ;
value "SUV-USA" / fillattrs=(color=orange) ;
value "Sedan-Asia" / fillattrs=(color=magenta) ;
value "Sedan-Europe" / fillattrs=(color=orange);
value "Sedan-USA" / fillattrs=(color=magenta);
value "Truck-Asia" / fillattrs=(color=grey) ;
value "Truck-USA" / fillattrs=(color=grey);
enddiscreteattrmap;
discreteattrvar attrvar=patgroup var=region_type attrmap='comboMap';
layout lattice / rows=2 columns=1 columndatarange=union ROWWEIGHTS=(.75 .25) ;
layout overlay /
xaxisopts=(label="Region" labelattrs=(size=12pt weight=bold)
tickvalueattrs=(size=12pt weight=bold))
yaxisopts=(offsetmin=0.05 offsetmax=0.05 label="Rating Score"
linearopts=(tickvaluesequence=(start=0 end=100 increment=10)));
boxplot x=region y=score /
name='BoxLegend'
group=patgroup
groupdisplay=cluster
boxwidth=0.6 clusterwidth=0.5
display=( median mean caps fillpattern )
medianattrs=(pattern=1);
endlayout;
discretelegend 'BoxLegend' /
border=false
valueattrs=(size=8pt weight = bold)
across=3 location=inside valign=top ;
endlayout;
endgraph;
end;
run;
proc template;
define style styles.mypatterns;
parent=styles.listing;
style GraphData1 from GraphData1 / fillpattern="R1" ;
style GraphData2 from GraphData2 / fillpattern="X1" ;
style GraphData3 from GraphData3 / fillpattern="E" ;
style GraphData4 from GraphData4 / fillpattern="R1" ;
style GraphData5 from GraphData5 / fillpattern="X1" ;
style GraphData6 from GraphData6 / fillpattern="E" ;
style GraphData7 from GraphData7 / fillpattern="R1" ;
style GraphData8 from GraphData8 / fillpattern="X1" ;
style GraphData9 from GraphData9/ fillpattern="E" ;
end;
run;
options orientation=landscape;
ods rtf file="boxplot_grouped.rtf" style=mypatterns;
ods graphics / reset width=8.5in height=5.5in border=off;
proc sgrender data=Dummy_cars_final template=boxplot_template;
run;
ods rtf close; Thank you.
... View more

0
28
Unanswered topics
These topics from the past 30 days have no replies. Can you help?