Hi Guys. Please help. I need to create a script that shows me how many records and variables are in that text file I'm working on
Can you show us a sample / example of the text file and how variables are delimited, e.g., tab character, comma, column position, etc.
Is the text file on Unix / Linux or DOS / Windows or Mainframe Operating System?
Any other information you could supply that you think would be useful.
Kind regards,
Amir.
Please post a few lines of the file into a window opened with the {i} button.
this is what I mean, I need to make sure that on the text files that am working on all this exacts headers are in the text file and currently I have to manually open the text file and make sure all these headers are on the text file so I'm wondering if there's any script to run that will show me that there's 532 headers in that file, not more not less because if theres more it means I have run a wrong product. This is part of my QA. Please help
HD003 | EQ001 | EQ002 | EQ003 | EQ004 | EQ005 | EQ006 | EQ007 | EQ008 | EQ009 | EQ010 | EQ011 | EQ012 | EQ013 | EQ014 | EQ015 | EQ016 | EQ017 | EQ018 | EQ019 | EQ020 | EQ021 | EQ022 | EQ023 | EQ024 | EQ025 | EQ026 | EQ027 | EQ028 | EQ029 | EQ030 | EQ034 | EQ035 | EQ036 | EQ037 | EQ038 | EQ039 | EQ040 | EQ041 | EQ042 | EQ043 | EQ044 | EQ045 | EQ046 | EQ047 | EQ048 | EQ049 | NQ001 | NQ002 | NQ003 | NQ007 | NQ008 | NQ009 | NQ010 | NQ011 | NQ012 | NQ013 | NQ014 | NQ015 | NQ016 | NQ017 | NQ018 | NQ019 | NQ020 | NQ021 | DF001 | DF002 | DF005 | DF006 | DF007 | DF008 | DF009 | DF010 | DF011 | DF015 | DF016 | DF023 | DF024 | DF025 | DF026 | DF027 | DF028 | JD001 | JD005 | JD006 | JD007 | JD008 | JD009 | JD010 | JD011 | JD012 | JD013 | JD014 | JD015 | JD016 | JD018 | JD020 | JD022 | JD023 | JD024 | JD025 | NG001 | NG005 | NG006 | NG007 | NG008 | NG009 | NG010 | NG011 | NG012 | NG013 | NG014 | NG024 | NG025 | NT001 | NT009 | NT010 | NT011 | NT012 | NT013 | NT014 | NT015 | NT016 | TA001 | TA002 | TA003 | TA004 | TA005 | TA006 | TA007 | PP001 | PP002 | PP003 | PP004 | PP005 | PP006 | PP010 | PP011 | PP012 | PP016 | PP018 | PP019 | PP020 | PP021 | PP023 | PP024 | PP025 | PP026 | PP028 | PP029 | PP030 | PP031 | PP032 | PP033 | PP035 | PP039 | PP040 | PP041 | PP042 | PP043 | PP044 | PP045 | PP046 | PP047 | PP049 | PP050 | PP059 | PP063 | PP074 | PP089 | PP103 | PP105 | PP106 | PP107 | PP108 | PP109 | PP110 | PP111 | PP112 | PP113 | PP114 | PP115 | PP116 | PP126 | PP135 | PP136 | PP137 | PP138 | PP139 | PP140 | PP141 | PP142 | PP143 | PP144 | PP145 | PP146 | PP147 | PP148 | PP149 | PP150 | PP151 | PP152 | PP153 | PP154 | PP155 | PP156 | PP157 | PP158 | PP159 | PP160 | PP161 | PP162 | PP163 | PP164 | PP165 | PP166 | PP167 | PP168 | PP169 | PP170 | PP171 | PP172 | PP173 | PP174 | PP175 | PP176 | PP177 | PP178 | PP179 | PP180 | PP181 | PP182 | PP183 | PP186 | PP187 | PP188 | PP189 | PP190 | PP191 | PP192 | PP193 | PP194 | PP195 | PP196 | PP197 | PP198 | PP199 | PP200 | PP201 | PP202 | PP203 | PP204 | PP205 | PP206 | PP207 | PP208 | PP209 | PP210 | PP211 | PP212 | PP213 | PP214 | PP215 | PP216 | PP217 | PP218 | PP219 | PP220 | PP221 | PP222 | PP223 | PP224 | PP225 | PP226 | PP227 | PP228 | PP229 | PP230 | PP231 | PP232 | PP233 | PP237 | PP238 | PP239 | PP240 | PP241 | PP242 | PP243 | PP244 | PP245 | PP246 | PP247 | PP248 | PP249 | PP250 | PP251 | PP252 | PP253 | PP254 | PP255 | PP256 | PP257 | PP258 | PP259 | PP260 | PP261 | PP262 | PP263 | PP264 | PP290 | PP291 | PP292 | PP293 | PP294 | PP295 | PP296 | PP297 | PP298 | PP301 | PP302 | PP303 | PP304 | PP305 | PP306 | PP307 | PP308 | PP309 | PP310 | PP311 | PP312 | PP313 | PP314 | PP315 | PP316 | PP317 | PP318 | PP319 | PP320 | PP321 | PP322 | PP323 | PP324 | PP325 | PP326 | PP327 | PP328 | PP329 | PP330 | PP331 | PP332 | PP333 | PP334 | PP335 | PP336 | PP337 | PP338 | PP339 | PP340 | PP341 | PP342 | PP343 | PP344 | PP345 | PP346 | PP347 | PP348 | PP349 | PP350 | PP351 | PP352 | PP353 | PP354 | PP355 | PP356 | PP357 | PP358 | PP359 | PP360 | PP361 | PP362 | PP363 | PP364 | PP365 | PP366 | PP367 | PP368 | PP369 | RE001 | RE002 | RE003 | RE004 | RE005 | RE006 | RE015 | RE020 | RE021 | RE022 | IN001 | IN002 | IN003 | IN004 | IN005 | IN006 | IN020 | IN021 | IN022 | DP001 | DP010 | DP013 | DP018 | JN001 | JN010 | JN013 | JN018 | SP001 | SP003 | SP004 | SP006 | SP007 | SP009 | SP010 | SP012 | SP013 | SP015 | NP001 | NP002 | NP003 | NP004 | NP005 | NP006 | NP010 | NP011 | NP012 | NP016 | NP017 | NP018 | NP019 | NP020 | NP021 | NP022 | NP023 | NP024 | NP025 | NP031 | NP033 | NP039 | NP040 | NP041 | NP042 | NP044 | NP045 | NP047 | NP057 | NP103 | NP104 | NP105 | NP106 | NP107 | NP108 | NP109 | NP110 | NP111 | NP113 | NP147 | NP186 | NP187 | NP188 | NP189 | NP190 | NP191 | NP192 | NP193 | NP194 | NP195 | NP196 | NP197 | NP198 | NP199 | NP200 | NP201 | NP202 | NP203 | NP204 | NP205 | NP206 | NP207 | NP208 | NP209 | NP210 | NP211 | NP212 | NP213 | NP214 | NP215 | NP216 | NP217 | NP218 | NP219 | NP220 | NP221 | NP222 | NP223 | NP224 | NP225 | NP226 | NP227 | NP228 | NP229 | NP230 | NP231 | NP232 | NP233 | NP239 | NP240 | NP241 | NP242 | NP243 | NP244 | NP245 | NP246 | NP247 | NP262 | NP278 | NP279 | NP280 | NP281 | NP282 | NP283 | NP284 | NP285 | NP286 |
What does your text file look like? What you posted into the forum looks like an HTML table. Perhaps that is because your text file is using tabs as the delimiter? Perhaps it is because you opened the text file with Excel or some other program that converted the text into cells in a table?
You might want to also look at the names of the columns and not just the number of them to make sure you have the right file.
So if the file is using TAB as the delimiter and there are no more than 1,000,000 bytes in the first line here is a program generate a dataset with the names of the columns. It will also print the number of columns in the log and set a macro variable to the number. For other delimiters change the DLM= (aka DELIMITER=) option.
data names ;
if eof then do;
put 'There are ' column 'columns in this file.';
call symputx('num_columns',column);
end;
infile 'myfile' dsd dlm='09'x truncover end=eof lrecl=1000000 obs=1;
column+1;
input name :$32. @@;
run;
yes the file is tab delimited and I opened the text file with excel so that I can count the number of headers.
Thank you so much, I'll try this script
You use '09'x to represent a TAB in the infile statement. Also make sure to include OBS=1 in the infile statement or it will read the whole file!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.