Recently in the SAS Community Library: SAS' @AndyRavenna publishes the second of two posts that uses statistics and machine-learning objects in SAS Visual Analytics to address real-world business problems.
Hi, ¨Why don¨'t strawberry print out in this code? (this is just fiction dataset that I created, they don't both come from WORK. Banana comes from ex libname Africa, and strawberry from UK. So I want to have them seperated. Thanks! data banana;
length banana 8 fruit 8;
do year = 2014 to 2023;
date = input(cats(put(year, 4.), '1231'), yymmdd8.);
do i = 1 to 25;
customer = cats('Customer', (year - 2014) * 25 + i);
banana = round(ranuni(0) * 100, 0.01);
fruit = ceil(ranuni(0) * 2) - 1;
output;
if i <= 10 then do;
customer = cats('Customer', (year - 2014) * 25 + i);
banana = round(ranuni(0) * 100, 0.01);
fruit = ceil(ranuni(0) * 2) - 1;
output;
end;
end;
end;
format date yymmddn8.;
drop i year;
run;
data strawberry;
length strawberry 8 fruit 8;
do year = 2014 to 2023;
date = input(cats(put(year, 4.), '1231'), yymmdd8.);
do i = 1 to 25;
customer = cats('Customer', (year - 2014) * 25 + i);
banana = round(ranuni(0) * 100, 0.01);
fruit = ceil(ranuni(0) * 2) - 1;
output;
if i <= 10 then do;
customer = cats('Customer', (year - 2014) * 25 + i);
strawberry = round(ranuni(0) * 100, 0.01);
fruit = ceil(ranuni(0) * 2) - 1;
output;
end;
end;
end;
format date yymmddn8.;
drop i year;
run;
%macro check_column_types(libname=, memname=,);
proc contents data=&libname..&memname out=columns_info(keep=name type);
run;
/* Skapa temp-dataset */
data column_types;
set columns_info;
/*ATTRN (en sas-funktion som används för att hämta attribut för en variabel i ett dataset) bestämemer datatypen*/
array char_cols[*] _character_;
array num_cols[*] _numeric_;
do i = 1 to dim(char_cols);
if vname(char_cols[i]) = name then do;
column_type = 'CHAR';
output;
end;
end;
do i = 1 to dim(num_cols);
if vname(num_cols[i]) = name then do;
column_type = 'NUM';
output;
end;
end;
run;
proc print data=column_types noobs;
title 'BANANA NNANANBANANABNASBA';
run;
/* Rensa temp-datasets */
proc datasets library=work nolist;
delete columns_info column_types;
quit;
%mend;
%check_column_types(libname=work, memname=banana);
%macro check_column_types(libname=, memname=,);
proc contents data=&libname..&memname out=columns_info(keep=name type);
run;
/* Skapa temp-dataset */
data column_types;
set columns_info;
/*ATTRN (en sas-funktion som används för att hämta attribut för en variabel i ett dataset) bestämemer datatypen*/
array char_cols[*] _character_;
array num_cols[*] _numeric_;
do i = 1 to dim(char_cols);
if vname(char_cols[i]) = name then do;
column_type = 'CHAR';
output;
end;
end;
do i = 1 to dim(num_cols);
if vname(num_cols[i]) = name then do;
column_type = 'NUM';
output;
end;
end;
run;
proc print data=column_types noobs;
title 'STRAWBERRY BERYRYEYRYRWEBERBE';
run;
/* Rensa temp-datasets */
proc datasets library=work nolist;
delete columns_info column_types;
quit;
%mend;
%check_column_types(libname=work, memname=strawberry);
... View more
Hi guys, suppose to have the following:
data DB;
input ID ID2;
cards;
0001 .
0001 .
0001 .
0001 .
0002 .
0002 0002
0002 0002
0003 0003
0003 .
...;
Is there a way to get the following?
data DB1;
input ID ID2;
cards;
0002 .
0002 0002
0002 0002
0003 0003
0003 .
...;
In other words if an ID is absent in column ID2 then delete. I tried with if statement without success maybe because there are other missing values in ID2. Can anyone help me please?
... View more
Hello SAS Community!
Is there a way in which I could parse and read sas logs and retrieve the information that SAS DI illustrates in the picture below?
Thank you in advance.
... View more
Hi, I need help for Table of content creation while combining RTF. When I created individual Tables RTF output I have used footnote statement instead line statement under proc report. so now I have empty space between end of table and footnote (due to footnote at end of page). When I write below code ,TOC text is printing in between empty space of table end and footnote. so it is giving incorrect page number for Table of contents. ods rtf text = "^S={outputwidth=100% just=l font_face='Tahoma' font_size=3.0}{\tc\fs0\cf8 &&ttl&i.}"; As an example . Table1 TOC text is printing on previous page which is Table of content page so it is giving page 1 but Table is starting from page 2. same as Table 2 TOC text is printing between table 1 end and footnote so on TOC page for Table 2 it has page number 2 but it should be page 3. if I change footnote with line statement then footnote is printing directly under end of table and thus no empty space so each TOC text printing at top of each table and it is giving correct page number since TOC text at top of each table. in this case for Table 1 page number 2 and table 2 page number 3 and 1st page is TOC page. Can someone let me know if there is any way to correct TOC page number when footnote statement was used for footnote instead line statement.
... View more
Hello Community,
I am dealing with Proc ARIMA for outliers detection, I would like to output the dataset with the outliers dates by a variable:
/*-- Outlier Detection --*/
proc arima data=CASUSER.ds out=ds_outliers;
identify var=dk noprint;
by region;
estimate method=ml;
outlier id=date;
run;
This is the output for a single region, I would like to flag the outliers in my original dataset. I checked and with out= option the is just statistics of the model.
... View more