BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
marianhabesland
Calcite | Level 5

I am trying to use deminited raw data to create a table with two variables with their populations. I wrote this code:

 

data WORK.Illus;
infile datalines delimiter= " ";

input      State        :$10.

              Population  :comma10.;

         datalines;

Washington 7,170,351

Ohio 11,613,423

;

 

I do not get any error statements, but my table looks like this. What do I do to get the entire state name and population values in the table?

Screen Shot 2017-09-21 at 10.26.31.png

1 ACCEPTED SOLUTION

Accepted Solutions
BD1
Calcite | Level 5 BD1
Calcite | Level 5

 

Have you tried dragging the state column width when you view the output table to see the whole state name?

For the values do you mean how do you get the commas appearing in your output table, just like your input datalines?

 

try adding the following line under your input statement:

 

format Population comma10.;

 

View solution in original post

4 REPLIES 4
Reeza
Super User

THis works for me.

 

I find it easier to set the INFORMAT first.

 

data WORK.Illus;
	infile datalines delimiter=" ";
	informat state $20. population comma20.;
	format population comma20.;
	input State Population;
	datalines;
Washington 7,170,351
Ohio 11,613,423
;
run;
ballardw
Super User

Try either widening the column for state or use Proc Print. I suspect the table viewer just isn't making the column wide enough to see the whole state name.

 

If you mean that you also want to display the population with commas then you need to explicitly assign a comma format for display.

 

Format population comma11.;

 

Since formats only control display not values SAS will unless otherwise instructed default to a BEST format to display numeric values.

 

Note that you may need a different delimiter to deal with New York, New Mexico, North and South Dakota, North and South Carolina if they are in your future data to read this way.

BD1
Calcite | Level 5 BD1
Calcite | Level 5

 

Have you tried dragging the state column width when you view the output table to see the whole state name?

For the values do you mean how do you get the commas appearing in your output table, just like your input datalines?

 

try adding the following line under your input statement:

 

format Population comma10.;

 

marianhabesland
Calcite | Level 5

Thanks, I didn't realize it was just the formatting of the table that did not let me see the whole variable. I thought it might be cutting it off for a reason. And yes, I wanted to display the commas, so that helps.

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 4 replies
  • 899 views
  • 0 likes
  • 4 in conversation