Dear all
I'm facing a problem with the new SAS OnDemand. I've already performed PS matching analyses on the virtual machine and everything was working good.
Now, when I run the same programmes OnDemand, I'm encountering some problems.
More in details:
1) I've created a psmatched dataset with all the variables of interest
2) I can pair the data creating two different datasets (matched_continuous and matched_categorical)
3) now the problem! when I write the program for matched analysis (group variables are named as 1 and 2)
DATA mAge;
SET dswi.pairedcontinuous;
WHERE Variables='Age_recalc';
RUN;
PROC TTEST data= mAge;
PAIRED _1*_2 ;
RUN;
I found in the Log
PAIRED _1*_2 ;
ERROR: Variable _1 not found.
ERROR: Variable _2 not found.
This code was well functioning when running SAS on the virtual maching. What's going wrong now?
Thank You all in advance for Your precious help and support!!!
So different values of the VALIDVARNAME option is the issue. If you have it set to the normal VALIDVARNAME=v7 then values of GROUP that look like the numbers 1 and 2 will be converted into _1 and _2 so that the resulting variable names are valid SAS names. But if instead you have told SAS you are fine if it makes variables names that are not valid SAS names then the names will just be the single digits 1 and 2. Which means that to reference the names in the code you need to use name literals.
paired '1'n*'2'n;
You could also just tell PROC TRANSPOSE to always use underscore as the prefix when defining the varible names.
PROC TRANSPOSE data=matchedsorted out=dswi.pairedcontinuous name=Variables prefix=_;
Then it won't generated invalid names for values like 1 and 2 (although it might for other values).
You are showing the wrong part of the code. We need to see the code that created the dataset dswi.pairedcontinuous to understand why the variables are not named _1 and _2.
Perhaps it is as simple as you accidentally run it with validvarname=any and it created variables named '1'n and '2'n instead.
Dear Tom
here is the code
PROC SORT data=dswi.matchedunpaired out=matchedsorted; BY _MatchID Group; RUN; PROC TRANSPOSE data=matchedsorted out=dswi.pairedcontinuous name=Variables; BY _MatchID; VAR Age_recalc EuroScoreII ICU LenghtOfStay; ID Group; RUN;
In the output dataset, the variables are named 1 and 2.
So different values of the VALIDVARNAME option is the issue. If you have it set to the normal VALIDVARNAME=v7 then values of GROUP that look like the numbers 1 and 2 will be converted into _1 and _2 so that the resulting variable names are valid SAS names. But if instead you have told SAS you are fine if it makes variables names that are not valid SAS names then the names will just be the single digits 1 and 2. Which means that to reference the names in the code you need to use name literals.
paired '1'n*'2'n;
You could also just tell PROC TRANSPOSE to always use underscore as the prefix when defining the varible names.
PROC TRANSPOSE data=matchedsorted out=dswi.pairedcontinuous name=Variables prefix=_;
Then it won't generated invalid names for values like 1 and 2 (although it might for other values).
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.