Recently in the SAS Community Library: SAS' @Sundaresh1 highlights a sometimes overlooked task when applying document embeddings for purposes of similarity-based search. Normalisation of vectors helps obtain relevant matches.
Hello! I have a table that I have to export to excel using a proc report, where subtotals rows are computed for certain numeric columns. My problem is that in the table(so before the proc report) I also created a check variable (like if col A + col B = col C then "true" else "false") that need to be calculated only for the subtotal rows. Is ther a way to write this in a proc report
... View more
Hi everyone - a bit newer to SAS and running into a problem trying to adapt someone's older code. Essentially I have a character variable with responses, and am coding in skips to it. e.g. Add skip coded 777 into the open text variable OPENTEXT1 if responses are blank OPENTEXT1 has character responses maxing out at 161 characters, proc contents show format=161 informat=$161. Check responses with proc freq, all 777 and responses are normal Then I create a "label" using the proc format function with value to label the skip and keep responses proc format; value OPENTEXT '777'="Skip"; run; data dataset1; set dataset; format OPENTEXT $OPENTEXT. proc freq, this time 777 show "SKIP" but other responses truncated to 4 characters I checked proc contents, and it is still showing format and informat still remaining at the same length. Any help appreciated
... View more
Hello, I have a couple of case when statements that will be used in about 18 different proc SQL programs within a project. Rather than copying and pasting the case when statements in each program, I'm wondering if there's a way for me to create a macro that stores the case when statements so that I can reference the macro from each of the programs. The first macro is quite simple. I have a variable that has a few invalid values that must be mapped to valid ones. However, the vast majority of observations can remain as they are. My case when statement is structured as follows: (CASE /*if variable is an invalid value, return its valid equivalent*/
WHEN VARIABLE = INVALID_VALUE1 THEN VALID_VALUE1
WHEN VARIABLE = INVALID_VALUE2 THEN VALID_VALUE2
... /*otherwise, return the variable as-is*/
ELSE VARIABLE END) as VARIABLE_CORRECTED, This is what I've tried, but it didn't work: %macro variable_crosswalk(variable);
%if &variable = 'invalid_value1' %then %let ;
&variable = 'valid_value1'; %end;
%else %if &variable = 'invalid_value2' %then %do;
&variable = 'valid_value2'; %end;
...
%else %do;
&variable
%end;
%mend; The second case when statement I'd like to store in a macro is a little more complicated. It uses several different race/ethnicity fields to calculate a person's race. It's structured as follows: (case
when race1 = 1 then 'Race 1'
when race8 = 2 then 'Race 2'
...
when race1 = 1 and race2 = 2 then 'Two or More Races' when race1 = 1 and race3 = 3 then 'Two or More Races' /*all other possible race combinations*/
...
else 'Unknown' end) as Race_Ethnicity, Is there a way for me to store one or both of the case when statements above as macros that can be accessed from all 18 programs in my project? If so, can someone help me with the syntax? Thanks for any assistance you can provide!
... View more
Hi all, I have successfully created an annotated state map from geocoded address info using the states map. However, when I try to use the county map data set, it appears that the geocoding output does not match what information in the county map dataset. Here is a small program to illustrate the difficulty. Code doesn't get past proc gproject. It seems that the length of x and y of the map do not match the length of x and y in the geocoded output. thanks! Phil : libname lookup "D:\Documents\desi2023\frlanalyses\geocodedata__2006__ZIP4_Geocode_Data\data"; data zips; input c zip; anno_flag=1l cards; 1 65203 2 65211 3 65201 ; proc geocode /* Invoke geocoding procedure */ method=plus4 /* Specify geocoding method */ lookup=lookup.zip4 /* Lookup data from MapsOnline */ data=zips /* Input data set to geocode */ out=geocodedzips; /* Specify name of Output data set of locations */ run; data mocounties;set maps.counties;if state=29; data mocounties;set mocounties geocodedzips;run; proc gproject data=mocounties out=MOCountiesP; id state ; run; data my_map locations; set mocountiesP; if anno_flag=1 then output locations; else output my_map; run; data anno_locations; set locations; if c=1 then color="red"; if c=2 then color="bib"; if c=3 then color="viyg"; if c=4 then color="bippk"; xsys='2'; ysys='2'; hsys='3'; when='a'; function='pie'; rotate=360; size=.5; style='psolid'; output; length html $300; html='title='||quote(trim(left(citystate))||'0d'x||trim(left(put(zip,z5.)))); style='pempty'; color='deb'; output; run; pattern1 v=e; proc gmap data=mymap map=mymap anno=anno_locations; id county; choro segment / coutline=black levels=1 nolegend coutline=gray99;run;
... View more
I have a dataset with two columns v1 and v2. V1 consists of labels such as "Spam" or "Ham" and v2 consists of texts. The error is "Proc hptmine reports ERROR: Unable to load extension: (tkparse) A computational component or a required service component could not be loaded in SAS enterprise miner" when I turn the text parsing node.
... View more