BookmarkSubscribeRSS Feed
solelo
Calcite | Level 5

When I run a PROC SQL to create a table and in the table I'm retying the user IDs but counting the amount of jobs they have done it returns a C00xx numbers instead of the actual user ID, below is the code I'm using, it's pretty straight forward but it doesn't return the user ID at all with the count. If I remove the count it returns the user ID

 

PROC SQL ; 
    CREATE TABLE TEST_2 AS 
       SELECT USER_ID , 
       COUNT(JOBS_COMP) AS JOBS_LOW

   FROM MAIN_INFO WHERE JOBS_COMP <= 30 
     GROUP BY USER_ID ;

QUIT;

 MAIN_INFO

USER_IDJOB_DATEJOBS_COMP
AB1230205221

BA123

0407221
AB1230309221
BA1230615221
AC1230106221
CA1230513221
AC1230718221

 

Current Output

USER_IDJOBs_LOW
C00012

C0002

2
C00032
C00042

Desired Output

USER_IDJOBS_LOW
AB1232

BA123

2
AC1232
CA1232
5 REPLIES 5
PaigeMiller
Diamond | Level 26

Show us a portion of your data set MAIN_INFO as working SAS data step code (please test it before posting to make sure the code is working) which you can type in yourself or by following these instructions (and not in any other format). Show us a portion of the output that is not correct.

--
Paige Miller
ballardw
Super User

From the code shown and the description of " a C00xx numbers instead of the actual user id" it appears that one of these may be happening: The values of the User_id in that set are not as you expect or the variable that has the value you expect is not actually "User_id".

 

You might also show the LOG from running your code. Include the code and any notes. Copy the text from the LOG and paste into a text box opened on the forum with the </> icon that appears above the message window.

 


@solelo wrote:

When I run a PROC SQL to create a table and in the table I'm retying the user IDs but counting the amount of jobs they have done it returns a C00xx numbers instead of the actual user ID, below is the code I'm using, it's pretty straight forward but it doesn't return the user ID at all with the count. If I remove the count it returns the user ID

 

PROC SQL ; 
    CREATE TABLE TEST_2 AS 
       SELECT USER_ID , 
       COUNT(JOBS_COMP) AS JOBS_LOW

   FROM MAIN_INFO WHERE JOBS_COMP <= 30 
     GROUP BY USER_ID ;

QUIT;

 

 

PaigeMiller
Diamond | Level 26

There's nothing in your code that will turn the data you show into the output that you show.

 

Therefore, the problem is that the data in data set MAIN_INFO is not what you say it is; or the output data set TEST_2 is from some other code; or the code is not what you show us.

 

  • Please show us the entire LOG for this PROC SQL, copy the log as text and paste it into the window that appears when you click on the </> icon.
  • Please show us a screen capture (not typed) of the output data set TEST_2 so we can see portions of the data and the data set name.
  • Please show us a screen capture of the data set MAIN_INFO so we can see portions of the data and the data set name.

Example: here is a screen capture, you can see the data set name is SASHELP.CLASS. Use the "Insert Photos" icon to include your screen captures of the output and data; do not attach files.

 

PaigeMiller_0-1659372927762.png

 

--
Paige Miller
Tom
Super User Tom
Super User

What did you use to produce the first report you showed?  Did you run something like:

select * from main_table;

If so then the USER_ID you see in the column header of the report might be the LABEL attached to the variable and not the NAME of the variable.  Check the output of PROC CONTENTS for your MAIN_TABLE.

proc contents data=main_table;
run;
Sajid01
Meteorite | Level 14

The output is what can be expected from the code and the main info that has been provided in the code.
The main info does not have C0's. There will be none in the output.
To get them additional code will be needed to do the transformation. This depend on your business rules.

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 5 replies
  • 576 views
  • 1 like
  • 5 in conversation