BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
deepikaj
Calcite | Level 5

I have a program that use proc transpose and uses a numeric variable (value 0.12, 1, 2) as the id var. Proc transpose runs without errors, but when the next proc or datadtep use the var name, it gives error e.g. 0_12 does not exists.

Same code runs without issues from SAS 9.4

Is this a known issue with enterprise guide?

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

Look like you are using SAS/EG , and EG  use    options validvarname=any;    by default ,

therefore change it as  options validvarname=v7;

Xia Keshan

View solution in original post

6 REPLIES 6
ballardw
Super User

Post some example data and the code used or generated.

And 0_12 is not a valid SAS variable name normally so, it isn't surprising that it doesn't exist.

deepikaj
Calcite | Level 5

Hi,

Thanks for response. Below is the sample code and warning. Same code works fine in SAS 9.4

data test;
   input id $ x aval;
   datalines;
1001-101 0.35 1
1002-103 1 2
1002-104 3 1
1003-105 5 2
;

proc transpose data=test out=test1 prefix=x;
by id;
var aval;
id x;
run;

data test2(keep=id x0_35);
set test1;
run;

WARNING: The variable x0_35 in the DROP, KEEP, or RENAME list has never been referenced.

Ksharp
Super User

Look like you are using SAS/EG , and EG  use    options validvarname=any;    by default ,

therefore change it as  options validvarname=v7;

Xia Keshan

cwilson
Calcite | Level 5

Could you run Proc Contents on dataset test.  We need to know what variable name SAS DID assign to that transposed variable.

Is it possible that it did not include the 0?

proc contents data=test1 varnum ; * I like to use the varnum option to preserve the variable order ;

Maybe you could control the naming convention by creating a character variable as part of your "test" dataset and then use THAT as your id variable? like:

data test;
   input id $ x aval;
     length x_char $4 ;

     if x < 1 then x_char = put(x, z4.2) ;  /* using zero-filled format */
     else x_char = trim(left(x));
   datalines;
1001-101 0.35 1
1002-103 1 2
1002-104 3 1
1003-105 5 2
;
run ;

proc print data=test ;
run ;

proc transpose data=test out=test1 prefix=x;
by id;
var aval;
id x_char;
run;

proc contents data=test1 varnum;
run ;

cwilson
Calcite | Level 5

Ah, looks like xia keshan has the correct answer!

deepikaj
Calcite | Level 5

Yes, options validvarname=v7 worked. Thank you all and specially xia keshan.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 8927 views
  • 1 like
  • 4 in conversation