BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
alan_maxs
Calcite | Level 5
Hi Ksharp;
The code gives a warning!:

63 data have;
64 length start end $ 40;
65 set temp temp(rename=(from=to to=from));
66 run;
WARNING: The input data sets have specified several lengths for the to variable. The data may be truncated.

The final_want data set has only 6 rows ..
Any idea what's going on?

thanks!
Ksharp
Super User

Sorry. Change it into  the following

 

data have;
 length from to $ 40;
set temp ;
run;

 

 

But I only got zero obs. that means all these identip cg are linked by the level which has less than 3 count .

Tom
Super User Tom
Super User

Do you want both X and Y to have fewer than 3 occurrences? Or both? Or the combination of X and Y to appear less than 2 times?

 

data have;
 input id  x $ y $;
cards;
1 2 2
2 6 2
3 1 3
4 3 4
5 3 3
6 5 3
7 1 3
8 5 3
9 4 1
10 6 1
11 3 4
12 1 4
13 5 4
14 7 2
15 3 4
;
proc sql ;
  create table test1 as
  select *,count(*) as n_xy
       , (n_x <3 or n_y <3) as rule1
       , (n_x <3 and n_y <3) as rule2
       , (calculated n_xy<3) as rule3
  from (select *,count(*) as n_y
   from (select *,count(*) as n_x from have group by x) a
   group by y) b 
  group by x,y
  order by id
  ;
quit;

 

Obs   id    x    y    n_x    n_y    n_xy    rule1    rule2    rule3
 1     1    2    2     1      3       1       1        0        1
 2     2    6    2     2      3       1       1        0        1
 3     3    1    3     3      5       2       0        0        1
 4     4    3    4     4      5       3       0        0        0
 5     5    3    3     4      5       1       0        0        1
 6     6    5    3     3      5       2       0        0        1
 7     7    1    3     3      5       2       0        0        1
 8     8    5    3     3      5       2       0        0        1
 9     9    4    1     1      2       1       1        1        1
10    10    6    1     2      2       1       1        1        1
11    11    3    4     4      5       3       0        0        0
12    12    1    4     3      5       1       0        0        1
13    13    5    4     3      5       1       0        0        1
14    14    7    2     1      3       1       1        0        1
15    15    3    4     4      5       3       0        0        0

 

So which sets of records do you want to keep those based on RULE1 , RULE2 , RULE3 or some other value?

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 17 replies
  • 5448 views
  • 1 like
  • 6 in conversation