Hi, I'm new to SAS. I'm trying to understand the behavior of SPEDIS function. I ran below SAS code. data new;
a = spedis('uzfiy', 'fuziy');
run; According to my understanding from SAS documentation : Here, three operations are done Query | Keyword uzfiy fuziy Operation | Cost u - f => firstrep 200 z - u => replace 100 f - z => replace 100 so, the result should be total cost / length of query => (200 + 100 + 100)/ 5 = 80. But the actual result is 40. can you please give me the actual operations done in this case ? And is there a way to get the source code of SPEDIS function?
... View more
Hello,
I am using a macro funtion to download an xml file from a web site. It was working properly but since few days, we have the following errors. How do we solve that kind of issue?
ORDERDATE=20240701 ORDERTIME=080000 SURVEYNAME=BROKERS_QUEBEC_SURVEYS_RESPONSES " BROKERS_QUEBEC_SURVEYS_RESPONSES" 'you are an authorized user in stha8n09z' SYS_PROCHTTP_STATUS_CODE=200 { "access_token": "51ebfa1c-7c45-4305-9658-9fa0008d91b3", "token_type": "Bearer", "expires_in": 3599, "scope": "manage:all" } BEARERTOKEN=...0008d91b3 BTEXPIN= 3599 BEARERTIMER_START=2035560918.51997 "===================================================================" SURVEYID=SV_0vnXEeLgN8B46bA ZNAME=Zfile13 "===========WE ARE STARTING TO PROCESS SURVEY SV_0vnXEeLgN8B46bA ===========" "========================== PROGRESSID=ES_aVJxgqv3peSjDkG ==========================" PSTATUS=inProgress PSTATUS=inProgress PSTATUS=inProgress PSTATUS=complete FILEID=c33612d3-e2dd-45d1-bef4-aeee06e12397-def Archive: /finsys/.../data/Zfile13.zip inflating: /finsys/.../data/Virage Survey.xml XMLFILE=Virage Survey.xml XMLFILE2=VirageSurvey.xml XMLMAP2=VirageSurvey.map FILE_PATH=/finsys/.../data ERROR: Some code points did not transcode. occurred at or near line 160740, column 109 ERROR: XML parsing error. Please verify that the XML content is well-formed. ERROR: File WORK.Response.DATA has not been saved because copy could not be completed. ERROR: Some code points did not transcode. occurred at or near line 160740, column 109 ERROR: XML parsing error. Please verify that the XML content is well-formed. ERROR: File WORK.Responses.DATA has not been saved because copy could not be completed.
Partial code inside a macro function:
filename oscmd pipe "unzip -d &file_path. -jo &file_path./&Zname..zip";
data _null_;
infile oscmd;
input;
put _infile_;
run;
/******* Get the xml file name********/
Filename adb_xml pipe "ls -Art &file_path./*.xml | tail -n 1 ";
DATA xml_filelist;
Infile adb_xml truncover;
Input infile_name $100.;
Filename=scan(infile_name,-1,"/","b");
call symput ('xmlFile',strip(Filename));
call symput ('cn_xmlFile1',strip(infile_name));
RUN;
/** Declaring other macro variables
Please don't move those macro. They need the value of xmlFile from the
above call symput statement ***/
%let xmlFile2=%sysfunc(compress(&xmlFile));
%let xmlMap2=%substr(&xmlFile2.,1,%length(&xmlFile2.)-4).map;
%put &=xmlFile;
%put &=xmlFile2;
%put &=xmlMap2;
%put &=file_path.;
/** Renaming the XML File with SAS standard (no space in the file name) ***/
filename oscmd pipe "mv ""&file_path./&xmlFile."" ""&file_path./&xmlFile2."" 2>&1";
data _null_;
infile oscmd;
input;
put _infile_;
run;
/********** Creating the map file ***************/
filename datafile "&file_path./&xmlFile2.";
filename mapfile "&file_path./&xmlMap2.";
libname datafile xmlv2 xmlmap=mapfile automap=replace;
proc copy in=datafile out=work;
run;
%goto exit;
Errors appears when the proc copy is executed
... View more
I have this table. We need to make sure to keep only dates for variable DATE_DOSE2 that occur after DATE_DOSE1 by ID. This is a sample table. The resulting dataset should delete row 4 for ID=A since DATE_DOSE2 happens before DATE_DOSE1. What code do you recommend? data dsin;
input ID $ SESSION DATE_DOSE2 : mmddyy10. DATE_DOSE1 : mmddyy10.;
format DATE_DOSE2 DATE_DOSE1 mmddyy10.;
datalines;
A 2 02/03/2021 .
A 2 02/04/2021 .
A 2 02/05/2021 .
A 2 01/06/2020 .
A 1 . 02/20/2020
B 2 04/16/2021 .
B 2 04/17/2021 .
B 2 04/18/2021 .
B 1 . 02/21/2020
;
run;
... View more
I have a situation that requires knowing what a data set list expansion will be, regardless of common variable types being mixed, or of differing lengths.
Consider the complicated scenario that has a combination of single data sets, name prefix lists and numbered range lists.
data x_a ; x=1 ; a='abc' ; do i=1 to 4 ; output ; end ;
data x_b ; x=1 ; a='defg' ; b='xyzzy' ; do i=1 to 4 ; output ; end ;
data x_d ; y=1 ; b='xyz' ; a='pqrstuv' ; i=1; stop ;
data x_f ; x='aaa' ; f='pqr' ; do i=1 to 4 ; output ; end ;
data y1 y2 y3 y4 y9 y10 y11; qqq='rrr' ; do i=1 to 4 ; output ; end ;
The following code captures the data set names, except for the one that has zero rows.
* no multiple length warning, because drop=_all_ ==> no variables;
* one record per input data set (that contains at least one row) ;
* output does not contain dataset='X_D' ;
options obs=1;
data datasets;
set x_:(drop=_all_) y1-y4(drop=_all_) y9(drop=_all_) indsname=libmem ;
dataset = libmem ;
run ;
options obs=max;
NOTE: There were 1 observations read from the data set WORK.X_A.
NOTE: There were 1 observations read from the data set WORK.X_B.
NOTE: There were 0 observations read from the data set WORK.X_D.
NOTE: There were 1 observations read from the data set WORK.X_F.
NOTE: There were 1 observations read from the data set WORK.Y1.
NOTE: There were 1 observations read from the data set WORK.Y2.
NOTE: There were 1 observations read from the data set WORK.Y3.
NOTE: There were 1 observations read from the data set WORK.Y4.
NOTE: There were 1 observations read from the data set WORK.Y9.
NOTE: The data set WORK.DATASETS has 8 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
Obs dataset
1 WORK.X_A
2 WORK.X_B
3 WORK.X_F
4 WORK.Y1
5 WORK.Y2
6 WORK.Y3
7 WORK.Y4
8 WORK.Y9
Short of writing my own name list expansion routine, is there a way to capture the no rows table?
... View more
I've got a pretty simple macro to take values from a list of strings and use them to name datasets. I use the variable "yearcounter" represent the actual value of where we are in the list. When I try to create a dataset name with it, I get the error NOTE: Line generated by the macro variable "YEARCOUNTER".
work.year_1998
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, /, ;, _DATA_, _LAST_, _NULL_.
ERROR 200-322: The symbol is not recognized and will be ignored. So it's placing the year in the right spot, but it's not interpreting the whole line of code. If I replace the [yearcounter] variable with [i], it runs fine with no problems, but then I get datasets with names like year_1, year_2, and so forth. Any idea what's going on? data yearlist;
input term;
datalines;
1998
1999
2000
2001
2002
2003
2004
2005
2006;
run;
proc sql;
select year into :Yearlist separated by ' '
from yearlist;
quit;
%macro classes;
%do i = 1 %to %sysfunc(countw(&Yearlist,%str( )));
%let yearcounter = %qscan(&Yearlist,&i,%str( ));
data work.year_&yearcounter;
set otherdataset;
[dataset operations]
run;
%end;
%mend;
%classes;
... View more