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;
Is there an error in the SASLOG? Show us the SASLOG.
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;
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.
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)
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.
Ah okay. This is exactly what is happening. The label doesn't change. Thank you.
SAS Output Variable Type Len Format Informat Label132
ID | Char | 200 | |||
MKTSHR | Num | 8 | |||
dominant | Char | 2 | $2. | $2. | car_code |
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.