BookmarkSubscribeRSS Feed
radha009
Quartz | Level 8

I have top 3 month apps.with same name. want to add month next to the data. is it possible to add or merge two variables

 

apps count

pmf    34

pmf    23

pmf    12

 

expected

 

apps           count

pmf (march)   34

pmf (feb)        23

pmf (jan)         12

2 REPLIES 2
Reeza
Super User

@radha009 wrote:

I have top 3 month apps.with same name. want to add month next to the data. is it possible to add or merge two variables

 

Yes, it's possible. What are the rules though, how do you know the first is March and the last is January?

What have you tried so far?

 

Spoiler

@radha009 wrote:

I have top 3 month apps.with same name. want to add month next to the data. is it possible to add or merge two variables

 

apps count

pmf    34

pmf    23

pmf    12

 

expected

 

apps           count

pmf (march)   34

pmf (feb)        23

pmf (jan)         12


radha009
Quartz | Level 8

Proc sql;
Create table work.Ent_L2_Apps as
SELECT Affected_CI, COUNT(Affected_CI) as count
FROM dash.Ent_L2_inc  GROUP BY Affected_CI
HAVING COUNT (Affected_CI)=(
SELECT MAX(count)
FROM (
SELECT Affected_CI, COUNT(Affected_CI) as count
FROM dash.Ent_L2_inc
GROUP BY Affected_CI));
quit;

proc sql;
Create table work.Ent_L2_Apps1 as
SELECT Affected_CI, COUNT(Affected_CI) as count
FROM work.Ent_L2_prev  GROUP BY Affected_CI
HAVING COUNT (Affected_CI)=(
SELECT MAX(count)
FROM (
SELECT Affected_CI, COUNT(Affected_CI) as count
FROM work.Ent_L2_prev
GROUP BY Affected_CI));
quit;

proc sql;
Create table work.Ent_L2_Apps2 as
SELECT Affected_CI, COUNT(Affected_CI) as count
FROM work.Ent_L2_old  GROUP BY Affected_CI
HAVING COUNT (Affected_CI)=(
SELECT MAX(count)
FROM (
SELECT Affected_CI, COUNT(Affected_CI) as count
FROM work.Ent_L2_old
GROUP BY Affected_CI));
quit;

data dash.Ent_Top_apps;
set work.Ent_L2_Apps2(firstobs=1 obs=1) work.Ent_L2_Apps1 (firstobs=1 obs=1) work.Ent_L2_Apps (firstobs=1 obs=1);
run;

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!

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
  • 2 replies
  • 691 views
  • 0 likes
  • 2 in conversation