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?
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.;
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;
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.
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.;
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 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.