BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
antor82
Obsidian | Level 7

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!!!

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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).

View solution in original post

5 REPLIES 5
Tom
Super User Tom
Super User

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.

antor82
Obsidian | Level 7

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.

Tom
Super User Tom
Super User

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).

antor82
Obsidian | Level 7
Thank You very much! Now it works perfectly!!!
antor82
Obsidian | Level 7
Or, probably more easily….. if variables are named 1 and 2, why cannot I use their real name (although numerical) for the analyses?
When I tried
PAIRED 1*2
It returned an invalid name error (because they were recognised as numbers instead of variable names)…

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 705 views
  • 0 likes
  • 2 in conversation