BookmarkSubscribeRSS Feed
padmakumariMiriyala
Calcite | Level 5

I have data like this

data have;

infile datalines;

input policynumber$8.;

datalines;

m2227eqw,wy3747387,hsdahah

schaxnbbxc

847e7w87

47ew7837

ds6778989

fg848484,rt222222,y72378w

;

run;

how to find out count policy number ?

actual count is 10 but it count came 6.;

thanks in advanc

3 REPLIES 3
Patrick
Opal | Level 21

That's not about the count but about your input statement which only reads the first field per line (and you have 6 lines).

Steelers_In_DC
Barite | Level 11

Two things to point out.  You your length assignments are incorrect and you are only loading one column when you have three.

Hope this helps:

data have;

infile datalines dsd;

length policynumber1 policynumber2 policynumber3 $10.;

input policynumber1$ policynumber2$ policynumber3$;

datalines;

m2227eqw,wy3747387,hsdahah

schaxnbbxc,,

847e7w87,,

47ew7837,,

ds6778989,,

fg848484,rt222222,y72378w

;

run;

proc sql;

create table want as

select sum(count(policynumber1),count(policynumber2),count(policynumber3)) as count

from have;

Astounding
PROC Star

Here's an alternative that uses your original version of the data:

data have;

infile datalines dsd;

length policynumber $ 10;

input policynumber @@;

datalines;

m2227eqw,wy3747387,hsdahah

schaxnbbxc

847e7w87

47ew7837

ds6778989

fg848484,rt222222,y72378w

;

This code doesn't count the policy numbers, because your original code didn't count them.  But it does give you each policy number as a separate observation.

Good luck.

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
  • 3 replies
  • 592 views
  • 1 like
  • 4 in conversation