The LITI rule for Text Analytics that you didn’t know you needed…until now!
Recent Library Articles
Recently in the SAS Community Library: Customer complaint call transcripts can end up being quite verbose. SAS' @PeterChristie reveals how to distill relevant info using SAS Text Analytics.
Hello, so I was working on this macro to print the results of the id and each variable in a dataset if it is empty.
%macro filter_and_print(dataset, new_dataset, var_id);
%local dsid varnum varname vartype filter_condition;
/* Open the dataset */
%let dsid = %sysfunc(open(&dataset));
/* Check if dataset is opened successfully */
%if &dsid %then %do;
/* Get the number of variables in the dataset */
%let varnum = %sysfunc(attrn(&dsid, nvars));
/* Loop through variables */
%do i = 1 %to &varnum;
/* Get variable name and type */
%let varname = %qscan(%sysfunc(varname(&dsid, &i)), 1);
%let vartype = %sysfunc(vartype(&dsid, &i));
/* Determine filter condition based on variable type */
%if &vartype = C %then %do;
%let filter_condition = %sysfunc(quote(&varname)) = ' ';
%end;
%else %if &vartype = N %then %do;
%let filter_condition = %sysfunc(quote(&varname)) = .;
%end;
/* Create filtered dataset */
data &new_dataset;
set &dataset;
if &filter_condition;
run;
/* Print filtered dataset */
proc print; var &var_id &varname;
run;
%end;
/* Close the dataset */
%let dsid = %sysfunc(close(&dsid));
%end;
%else %put ERROR: Unable to open dataset &dataset;
%mend;
Right, so it does loop through each variable, if it is a character variable it checks if there is an empty string, if it is a numerical variable it checks if it is equal to .
Okay, so in the log, I get messages like
But using proc contents on the original dataset, I do see that the variable in question is numerical.
And I see the Note that says character values have been converted to numerical, but why would it be doing that?
I wouldn't recommend running the program with a large dataset though as it does take a bit of time to fully execute. I do get my printed results at the end of running the program, however it does not print out the empty/missing values as expected. It instead returns every observation but filtered by the id variable and the variable being observed.
Any help would be greatly appreciated. Thank you! 😁
... View more
Hello Experts,
I am having a database which contains more than 50 datasets. I need to check in which dataset a specific variable is available and also in a new dataset I need to save the result as 'yes' or 'no'.
Please guide me on below query
I wrote a code. But, I am seeing an empty dataset. I want results dataset as dataset name and Yes or no value in variables_exists variable.
If I want to search multiple variable means how I need to tweak my code
Code:
PROC SQL; SELECT MEMNAME INTO :DATASET_LIST SEPARATED BY ' ' FROM SASHELP.VTABLE WHERE LIBNAME='STPSAMP'; QUIT;
DATA RESULTS; LENGTH DATASET $32. VARIABLE_EXISTS $3.; STOP; RUN;
%MACRO CHECK_VARIABLE(VAR_NAME);
%LET DS_COUNT=%SYSFUNC(COUNTW(&DATASET_LIST.)); %DO i=1 %TO &DS_COUNT.; %LET DATASET=%SCAN(&DATASET_LIST.,&i.);
PROC SQL; SELECT MEMNAME,COUNT(*) INTO : DT_NAME, :VAR_EXISTS FROM DICTIONARY.COLUMNS WHERE LIBNAME='STPSAMP' AND MEMNAME="&DATASET." AND UPPER(NAME)="&VAR_NAME."; QUIT;
DATA _NULL_; DATASET=&DATASET.; VARIABLE_EXISTS=IFC("&VAR_EXISTS.">0,'YES','NO'); CALL SYMPUT("DATASET",DATASET); CALL SYMPUT("VARIABLE_EXISTS",VARIABLE_EXISTS); RUN;
DATA RESULTS; SET RESULTS; DATASET=SYMGET(DATASET); VARIABLE_EXISTS=SYMGET(VARIABLE_EXISTS); OUTPUT; RUN; %END;
%MEND CHECK_VARIABLE;
%CHECK_VARIABLE(QTR);
Thanks in Advance
... View more
Few business units using customized workspace folders instead of default work spaces (like /saswork, /tmp). Is there any way to check customized workspace configuration in SAS 9.4 M7?
... View more
PROC SGPANEL is a module with deficits. First, the user cannot specify the number of graphs in each row. Second, the graphs are automatically left-justified, with no way to correct them in the module.
It is therefore especially embarrassing when I am putting five graphs in one panel. PROC SGPANEL automatically assigns three graphs in the first row and two in the second. I cannot change the arrangement into two in the first and three in the second row.
What is more embarrassing is that the graphs in the second panel are automatically left-justified and there is no way I can tell SAS to change the alignment the graphs in the second row to middle-justified in PROC SGPANEL. What is more, PROC SGPANEL seems to be the only module capable of putting multiple graphs in one panel when there is no way of drawing them in statistical analytic modules.
In fact, I am drawing calibration plots of logistic regression models. With an older SAS version (TS1M5), I cannot do this in PROC LOGISTIC, so PROC SGPLOT and PROC SGPANEL are the only two modules I can resort to. But PROC SGPLOT does not support putting graphs in panels while PROC SGPANEL does not support the functions I mentioned above. It is really frustrating.
... View more
Hi: I would like to find documemtation in SAS, how the 'expected sum' and 'StdDev of sum' in SAS output are calculated. I want the formula. I cannot find it online so far. Background information: I am doing Multiple Imputation for my study. After getting analysis results (Wilcoxon rank sum test on each imputed data set), how should I combine to get a 'whole' p-value? My idea so far: get a mean of 'sum of scores' for m imputed data sets. Then calculate a 'z' on my own (need the formula here). then get the p-value just by normal distribution, initially, maybe by t distribution too. Any other formal/standard way to combine the results? It seems to me that the proc mianalyse in SAS is not applicable to my case? I am eagerly waiting for your expertise on this. Thanks. Xiaoshu
... View more