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?
Look like you are using SAS/EG , and EG use options validvarname=any; by default ,
therefore change it as options validvarname=v7;
Xia Keshan
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.
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.
Look like you are using SAS/EG , and EG use options validvarname=any; by default ,
therefore change it as options validvarname=v7;
Xia Keshan
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 ;
Ah, looks like xia keshan has the correct answer!
Yes, options validvarname=v7 worked. Thank you all and specially xia keshan.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.