DATA Step, Macro, Functions and more

Proc SQL does not rename one of the variables

Reply
Occasional Contributor
Posts: 10

Proc SQL does not rename one of the variables

For some reason SAS will not rename car_code as dominant, however, it names ID as TID. What could be the reason?

 

proc sql;
create table ASH.DOM as
Select ID as TID, car_code as dominant, MKTSHR from ASH.DATAN group by ID HAVING MKTSHR=MAX(MKTSHR);
quit;

Respected Advisor
Posts: 2,794

Re: Proc SQL does not rename one of the variables

Posted in reply to larusso522

Is there an error in the SASLOG? Show us the SASLOG.

--
Paige Miller
Occasional Contributor
Posts: 10

Re: Proc SQL does not rename one of the variables

Posted in reply to PaigeMiller

Here is the log:

493  proc sql;
494  create table ASH.DOM as
495  Select ID, car_code as dominant, MKTSHR from ASH.DATAN group by ID HAVING MKTSHR=MAX(MKTSHR);
NOTE: The query requires remerging summary statistics back with the original data.
NOTE: Table ASH.DOM created, with 24442 rows and 3 columns.

496  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.11 seconds
      cpu time            0.14 seconds

 

Also, I use that column to make further calculations in another program, and that program actually retrieves the values named "dominant" but in my datasets the name of the variable is still car_code. For example,

 

proc sql;
create table ASH.Datao as
Select a.*,b.dominant from ASH.Datan as a left outer join ASH.DOM as b on a.ID=b.ID;
quit;

Respected Advisor
Posts: 2,794

Re: Proc SQL does not rename one of the variables

Posted in reply to larusso522

Also, I use that column to make further calculations in another program, and that program actually retrieves the values named "dominant" but in my datasets the name of the variable is still car_code. For example,

 

proc sql;
create table ASH.Datao as
Select a.*,b.dominant from ASH.Datan as a left outer join ASH.DOM as b on a.ID=b.ID;
quit;


Based on what evidence are you saying that the variable is still named car_code? Please be very very specific explaining where you see this, or show us a screen capture.

--
Paige Miller
Occasional Contributor
Posts: 10

Re: Proc SQL does not rename one of the variables

Posted in reply to PaigeMiller

Untitled.png

Respected Advisor
Posts: 2,794

Re: Proc SQL does not rename one of the variables

Posted in reply to larusso522

These are the variable labels created in the SQL process.

 

You can switch VIEWTABLE to show the variable Names, its one of the menu options (I'm not able to run SAS at the moment so I can't be more specific, but I'm sure you can find it)

--
Paige Miller
Trusted Advisor
Posts: 1,157

Re: Proc SQL does not rename one of the variables

Posted in reply to larusso522

I suspect you see the label of the variable, not its name, as a column header perhaps in a VIEWTABLE window, SAS Universal Viewer or the like. PROC CONTENTS output should clarify this.

Occasional Contributor
Posts: 10

Re: Proc SQL does not rename one of the variables

[ Edited ]
Posted in reply to FreelanceReinhard

Ah okay. This is exactly what is happening. The label doesn't change. Thank you.

 

SAS Output                                                Variable      Type    Len      Format  Informat Label132

IDChar200   
MKTSHRNum8   
dominantChar2$2.$2.car_code
Ask a Question
Discussion stats
  • 7 replies
  • 139 views
  • 2 likes
  • 3 in conversation