BookmarkSubscribeRSS Feed
larusso522
Fluorite | Level 6

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;

7 REPLIES 7
PaigeMiller
Diamond | Level 26

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

--
Paige Miller
larusso522
Fluorite | Level 6

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;

PaigeMiller
Diamond | Level 26

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
PaigeMiller
Diamond | Level 26

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
FreelanceReinh
Jade | Level 19

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.

larusso522
Fluorite | Level 6

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

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!

How to Concatenate Values

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.

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
  • 7 replies
  • 2749 views
  • 2 likes
  • 3 in conversation