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
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
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
Esteemed Advisors:
I am trying to interleave two datasets with a condition that the resulting dataset contains only observations that can be found in both of the two datasets.
Below is exemplar code to illustrate the problem. If you run this code and inspect dataset interleave2 you will see that for a group of 3 observations where target=1, two came from Random_A and one came from Random_B. Likewise, for a group of three observations where target=2, two came from Random_B and one came from Random_A. All of these observations need to be retained in the desired dataset.
For the group of 3 observations where target=3, all observations came from Random_B only. These are ones that need to be omitted. All observations for a given target that come from a single source dataset are not to be retained in the desired dataset.
The challenge for me (and now for you) is to come up with the code that will interleave Random_A and Random_B such that the resultant dataset that only contains the groups of targets that are present in both datasets.
Hope this makes sense and thanks for taking a look,
Gene
data Random_A (drop=i);
call streaminit(4786);
do i=1 to 100;
Source="A";
Target=rand("Integer",1,100);
ST=catx('/',Source,Target);
output;
end;
data Random_B (drop=i);
call streaminit(6874);
do i=1 to 150;
Source="B";
Target=rand("Integer",1,100);
ST=catx('/',Source,Target);
output;
end;
Proc sort data=Random_A;
by ST;
run;
Proc sort data=Random_B;
by ST;
run;
data interleave1;
set random_A random_B;
by ST;
run;
proc sort data=interleave1 out=interleave2 nounikey;
by target;
run;
... View more
Dear All, I am quite a new user using SAS software. Please give me some suggestion base on the scenario below: 1. I have time series data for almost 2 years, which records the date and the amount of money that earn daily but in this case user record the data only weekdays (data for sat and sun is empty). 2. Base on the data i have, i try to identified, include dummy variables, estimate and got the satisfied model to do forecasting. This also include the cosscorr pamarameter. 3. However, when i try to run forecasting by using proc arima data=data ; identify var=money crosscorr=(Monday Tuesday Thursday Friday ); estimate input=(Monday Tuesday Thursday Friday ) p= (0) (21) q= (1) (0); forecast lead=30 interval=day id=date out=results; run; i got an error "The value for option LEAD= has been reduced to 0." and the results that i got is generate only for the trained variable. The lead forecasting is not generate for me. I am not sure the forecast syntax is working with my data struture or not. Please feel free to leave some comments on this or please share some ideas how can i solve this issue. Regards, santisouk
... View more