BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jc3992
Pyrite | Level 9
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!

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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; 

 

View solution in original post

1 REPLY 1
Tom
Super User Tom
Super User

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-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
  • 1 reply
  • 777 views
  • 2 likes
  • 2 in conversation