data googlestat; infile '/folders/myfolders/preprocessedgooglestatstab.txt' dlm='09'x dsd firstobs=2; input DayofWeek $ Date MMDDYY10. Impressions 5. Clicks 2. Revenue COMMA10.1; run; proc print data=googlestat; run;
Hello everyone,
I wonder which informat I should use for DayofWeek so the next observation which is the date would not be in the same column as DayofWeek? Thank you!
The main thing is to use LIST MODE input statement. So either remove the informats from the INPUT statement, or add : modifier in front of them.
You do not need to tell SAS to use an informat to read most values. Your example has two values where it is useful, a date and number with embedded thousands separators.
Your date values (at least the first few lines) can be read using the DATE informat.
Also note that if you are using LIST MODE input there is no need to specify the width on your INFORMAT since SAS will ignore them anyway. In list mode it adjusts the informat width to match the width of the data for that field.
Also you almost NEVER want to add a decimal specification to an informat. Do you really want any integer values divided by 10?
Also I like to use YYMMDD format to display dates to avoid confusion between locales that use MDY order and those that use DMY order. Did you mean November 12th or the 10th of December?
data googlestat;
infile '/folders/myfolders/preprocessedgooglestatstab.txt'
dlm='09'x dsd firstobs=2 truncover
;
length DayofWeek $10 Date 8 Impressions 8 Clicks 8 Revenue 8;
input DayofWeek Date :date. Impressions Clicks Revenue :comma.;
format date yymmdd10.;
run;
The main thing is to use LIST MODE input statement. So either remove the informats from the INPUT statement, or add : modifier in front of them.
You do not need to tell SAS to use an informat to read most values. Your example has two values where it is useful, a date and number with embedded thousands separators.
Your date values (at least the first few lines) can be read using the DATE informat.
Also note that if you are using LIST MODE input there is no need to specify the width on your INFORMAT since SAS will ignore them anyway. In list mode it adjusts the informat width to match the width of the data for that field.
Also you almost NEVER want to add a decimal specification to an informat. Do you really want any integer values divided by 10?
Also I like to use YYMMDD format to display dates to avoid confusion between locales that use MDY order and those that use DMY order. Did you mean November 12th or the 10th of December?
data googlestat;
infile '/folders/myfolders/preprocessedgooglestatstab.txt'
dlm='09'x dsd firstobs=2 truncover
;
length DayofWeek $10 Date 8 Impressions 8 Clicks 8 Revenue 8;
input DayofWeek Date :date. Impressions Clicks Revenue :comma.;
format date yymmdd10.;
run;
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.