Desktop productivity for business analysts and programmers

proc tranpose id numeric variable not working in enterprise guide

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

proc tranpose id numeric variable not working in enterprise guide

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?


Accepted Solutions
Solution
‎01-15-2015 09:21 AM
Grand Advisor
Posts: 9,584

Re: proc tranpose id numeric variable not working in 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

View solution in original post


All Replies
Grand Advisor
Posts: 10,223

Re: proc tranpose id numeric variable not working in enterprise guide

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.

New Contributor
Posts: 3

Re: proc tranpose id numeric variable not working in enterprise guide

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.

Solution
‎01-15-2015 09:21 AM
Grand Advisor
Posts: 9,584

Re: proc tranpose id numeric variable not working in 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

Contributor
Posts: 43

Re: proc tranpose id numeric variable not working in enterprise guide

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 ;

Contributor
Posts: 43

Re: proc tranpose id numeric variable not working in enterprise guide

Ah, looks like xia keshan has the correct answer!

New Contributor
Posts: 3

Re: proc tranpose id numeric variable not working in enterprise guide

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

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

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