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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 6 replies
  • 7669 views
  • 1 like
  • 4 in conversation