<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Error Setting many datasets where same variable is char and num in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Error-Setting-many-datasets-where-same-variable-is-char-and-num/m-p/924191#M41455</link>
    <description>&lt;P&gt;I doubt that will work since you did not include the EOV= option on the INFILE statement.&lt;/P&gt;
&lt;P&gt;But you don't need it since you did include the FILENAME= option.&lt;/P&gt;
&lt;P&gt;So replace this line:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if eov then input;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;With&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if fname ne lag(fname) then input;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And remove this line:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;eov=0;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also not sure why you have the INFORMAT statement.&amp;nbsp; None of the variables listed require any special informats to be read properly. The informats you are attaching are what will be used anyway (BEST is really the name of a FORMAT and using it as an INFORMAT name will just result in the normal numeric infomat being used).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It would be much clearer to have a LENGTH (or ATTRIB) statement to directly set the variable type and length instead of forcing SAS to guess what type and length to define them as based on information available at the time they are first used in some other statement (in this case the INFORMAT statement).&lt;/P&gt;</description>
    <pubDate>Fri, 12 Apr 2024 20:01:08 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2024-04-12T20:01:08Z</dc:date>
    <item>
      <title>Error Setting many datasets where same variable is char and num</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Error-Setting-many-datasets-where-same-variable-is-char-and-num/m-p/923960#M41437</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have hundreds of datasets of the same structure (i.e., all the same variable names) that I need to set into one dataset. I used the very helpful SAS &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/n0ctmldxf23ixtn1kqsoh5bsgmg8.htm" target="_self"&gt;macro&lt;/A&gt;&amp;nbsp;to import all of the csv files. They are each named DSN and appended with a count number (DSN1, DSN2, etc. up to 189). Now in attempting to set them, I am running into the dreaded error where a variable (in this case, Reaction_Time) is both character and numeric.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Instead of going into every single dataset and converting the variable before setting, I am hoping to be able to deal with this issue within the Set step.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've run this code and many tweaks of this code and I am still getting "ERROR: Variable rt has been defined as both character and numeric."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data combined;
set dsn: (rename=(Reaction_Time=rt));
rt = input(Reaction_Time, 8.);
run;&lt;/PRE&gt;&lt;P&gt;Can someone please point me in the right direction?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Apr 2024 13:36:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Error-Setting-many-datasets-where-same-variable-is-char-and-num/m-p/923960#M41437</guid>
      <dc:creator>davidsmarch1</dc:creator>
      <dc:date>2024-04-11T13:36:14Z</dc:date>
    </item>
    <item>
      <title>Re: Error Setting many datasets where same variable is char and num</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Error-Setting-many-datasets-where-same-variable-is-char-and-num/m-p/923963#M41438</link>
      <description>&lt;P&gt;Import while very helpful for single file reading is not the way to read multiple files of the same structure. Proc Import will make separate guesses based on the content of each file as to variable type and length. Different files, different properties.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If all of the files are supposed to be the same then the proper approach would be to write a data step that reads the variables with properties needed, which hopefully you have some documentation as to content to help with setting maximum lengths and proper informats for things like date or time values.&lt;/P&gt;
&lt;P&gt;Then once you have that program working replace the PROC IMPORT code in that macro with your data step to read the files and create the sets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or using wildcards in the infile statement a single data step can read all the files but which approach to take there can vary a bit depending on the actual content of&amp;nbsp; your files (multiple header rows for example add complexity [as well as typically messing with proc import])&lt;/P&gt;</description>
      <pubDate>Thu, 11 Apr 2024 13:53:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Error-Setting-many-datasets-where-same-variable-is-char-and-num/m-p/923963#M41438</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-04-11T13:53:21Z</dc:date>
    </item>
    <item>
      <title>Re: Error Setting many datasets where same variable is char and num</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Error-Setting-many-datasets-where-same-variable-is-char-and-num/m-p/923976#M41439</link>
      <description>&lt;P&gt;Generate a data step that can read one file.&amp;nbsp; You could start with the code that PROC IMPORT generates, but it is ugly and overcomplicated.&amp;nbsp; You could use the code that this macro generates instead&amp;nbsp;&lt;A href="https://github.com/sasutils/macros/blob/master/csv2ds.sas" target="_blank" rel="noopener"&gt;https://github.com/sasutils/macros/blob/master/csv2ds.sas&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then just modify it to handle all of the files in one step.&amp;nbsp; You might need to adjust the code so that it is compatible with all of the files (change the length of the character variables to handle the largest value for example).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's work an example.&amp;nbsp; Say you exported SASHELP.CARS to a CSV file and wanted to read it in.&amp;nbsp; You could use code like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data fromcsv;
  infile '/mydir/cars.csv' dsd truncover firstobs=2 ;
  length Make $13 Model $39 Type $6 Origin $6 DriveTrain $5 MSRP 8
    Invoice 8 EngineSize 8 Cylinders 8 Horsepower 8 MPG_City 8
    MPG_Highway 8 Weight 8 Wheelbase 8 Length 8
  ;
  informat MSRP comma. Invoice comma. ;
  format MSRP comma8. Invoice comma8. ;
  input Make -- Length ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To adjust it to read multiple files.&amp;nbsp; You could change the filename to use a wildcard so it matches multiple files.&amp;nbsp; Then add the FILENAME= option to the INFILE statement and remove the FIRSTOBS=2 option.&amp;nbsp; Then add data step code to skip the first line of each file.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data fromcsv;
  infile '/mydir/car*.csv' dsd truncover filename=fname ;
  length Make $13 Model $39 Type $6 Origin $6 DriveTrain $5 MSRP 8
    Invoice 8 EngineSize 8 Cylinders 8 Horsepower 8 MPG_City 8
    MPG_Highway 8 Weight 8 Wheelbase 8 Length 8
  ;
  informat MSRP comma. Invoice comma. ;
  format MSRP comma8. Invoice comma8. ;
  input @;
  if fname ne lag(fname) then delete;
  input Make -- Length ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Apr 2024 14:30:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Error-Setting-many-datasets-where-same-variable-is-char-and-num/m-p/923976#M41439</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-04-11T14:30:13Z</dc:date>
    </item>
    <item>
      <title>Re: Error Setting many datasets where same variable is char and num</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Error-Setting-many-datasets-where-same-variable-is-char-and-num/m-p/923999#M41443</link>
      <description>&lt;P&gt;Tom,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That seems like a useful start. The reason I used the other macro is that the csv files do not share a common prefix, so I cannot use a wildcard to read in all csv's in the directory. Do you have a suggestion for how to handle that within the example you posted? [Edit, I see I may be able to do something like&amp;nbsp;infile '(M:\FPST-VR Pilot Testing\*.csv' dsd truncover filename=fname; to gather all csv's.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My current outstanding issue is that the variable names have spaces within them. How do I use the Length statement with variables that will be renamed by SAS? Do I use the name SAS will give them?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Apr 2024 17:05:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Error-Setting-many-datasets-where-same-variable-is-char-and-num/m-p/923999#M41443</guid>
      <dc:creator>davidsmarch1</dc:creator>
      <dc:date>2024-04-11T17:05:08Z</dc:date>
    </item>
    <item>
      <title>Re: Error Setting many datasets where same variable is char and num</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Error-Setting-many-datasets-where-same-variable-is-char-and-num/m-p/924029#M41444</link>
      <description>&lt;P&gt;If there is no pattern to the names how do you know which ones you want?&lt;/P&gt;
&lt;P&gt;If you can make logic to select the files then just use a list of filenames.&amp;nbsp; You can easily use DREAD() function to get filenames and then apply logic to select the ones you want.&amp;nbsp; Don't do it in macro logic however, keep in it normal data step code so you have a dataset of the filenames and not a bunch of macro variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could then use the data step to drive the process.&amp;nbsp; So assume you had a dataset named LIST with variable named FNAME your code would look like like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data fromcsv;
  set list;
  infile dummy dsd truncover firstobs=2 filevar=fname end=eof;
  length Make $13 Model $39 Type $6 Origin $6 DriveTrain $5 MSRP 8
    Invoice 8 EngineSize 8 Cylinders 8 Horsepower 8 MPG_City 8
    MPG_Highway 8 Weight 8 Wheelbase 8 Length 8
  ;
  informat MSRP comma. Invoice comma. ;
  format MSRP comma8. Invoice comma8. ;
  do while (not eof);
    input Make -- Length ;
    output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Just because the column headers in the CSV file have spaces in them there is no reason to make the variable names have spaces.&amp;nbsp; So if the header text is 'First Name'&amp;nbsp; you could name the variable firstname or FirstName or first_name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you really do want to make variable names with sapces you will first have to set the VALIDVARNAME option to ANY instead of the normal V7 setting.&amp;nbsp; And then use name literals.&amp;nbsp; Then you could use 'First Name'n as the variable name in your SAS code.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Apr 2024 20:34:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Error-Setting-many-datasets-where-same-variable-is-char-and-num/m-p/924029#M41444</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-04-11T20:34:29Z</dc:date>
    </item>
    <item>
      <title>Re: Error Setting many datasets where same variable is char and num</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Error-Setting-many-datasets-where-same-variable-is-char-and-num/m-p/924030#M41445</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/360861"&gt;@davidsmarch1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Tom,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That seems like a useful start. The reason I used the other macro is that the csv files do not share a common prefix, so I cannot use a wildcard to read in all csv's in the directory. Do you have a suggestion for how to handle that within the example you posted? [Edit, I see I may be able to do something like&amp;nbsp;infile '(M:\FPST-VR Pilot Testing\*.csv' dsd truncover filename=fname; to gather all csv's.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My current outstanding issue is that the variable names have spaces within them. How do I use the Length statement with variables that will be renamed by SAS? Do I use the name SAS will give them?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If all of the CSV files in the folder have the same structur then M:\FPST-VR Pilot Testing\*.csv is indeed valid.&lt;/P&gt;
&lt;P&gt;I tend to place those into a FILENAME statement:&lt;/P&gt;
&lt;PRE&gt;Filename mycsv "M:\FPST-VR Pilot Testing\*.csv" ;

/* and read using*/
data mydata;
   infile mycsv dsd dlm=',' &amp;lt;other infile options&amp;gt;;
  &amp;lt; rest of the data step&amp;gt;
run;&lt;/PRE&gt;
&lt;P&gt;One reason is changing the filename lets me test code with just one (or a subset of the files) without modifying the data step (unless needed).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Pick reasonable names, Add reasonable labels to the variables.&lt;/P&gt;
&lt;P&gt;Also, depending on your data you may end up considering custom informats to read certain types of data. If you have values like "Yes"/"No", "True"/"false" you might want to consider an informat that reads them into a numeric 1/0 (for true/false) as there are many things that run much nicer with the numeric values. (Not to mention a properly designed informat will handle random case differences like Yes/yes/yEs and ONE informat can handle the yes/no, true/false values).&lt;/P&gt;
&lt;P&gt;Also if you have some source columns that insist on putting things like N/A or NULL into columns that should really be numeric you can fix that with a proper informat to read as numeric and assign missing (not to mention special missing values if you need to know the difference be N/A and NULL (or Refused , Not Collected or similar).&lt;/P&gt;</description>
      <pubDate>Thu, 11 Apr 2024 20:51:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Error-Setting-many-datasets-where-same-variable-is-char-and-num/m-p/924030#M41445</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-04-11T20:51:30Z</dc:date>
    </item>
    <item>
      <title>Re: Error Setting many datasets where same variable is char and num</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Error-Setting-many-datasets-where-same-variable-is-char-and-num/m-p/924190#M41454</link>
      <description>&lt;P&gt;Thank you for all of your suggestions. I ended up taking your advice and using a more controllable method. Here is what worked for me:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data combined;
	LENGTH fname $200;
    infile 'M:\FPST-VR Pilot Testing\TestLogs Data Collection\*.csv' delimiter = ',' dsd truncover filename=fname;
	informat 	Participant_ID best32.	Dominant_Hand $10.	Player_Height best32.	Trial_Count	best32. Ambient_light	best32. Debris best32.
		Hallway_Length best32.	Background	$29. 	Ethnicity $5.	Gender $4.	Weapon $15. 	Spawn_Point $3.	Distance_From_Player best32.
		Target_Height best32.		Height_Difference best32. Prefade_Time best32.	Shadow_Fade_Time best32.	Reaction $15.	Reaction_Time $5.	
		Miliseconds best32.	Left_hand_pitch best32.	Left_hand_Yaw best32.	Left_hand_Roll best32.	Left_hand_Trigger_Press__ best32.	Left_hand_Grip_Press__ best32.	
		Left_Hand_position_X best32.	Left_Hand_position_Y best32.	Left_Hand_position_Z best32.	Right_Hand_pitch best32.	Right_Hand_Yaw	best32.
		Right_Hand_Roll best32.	Right_Hand_Trigger_Press__ best32.	Right_Hand_Grip_Press__	best32. Right_Hand_position_X best32.	Right_Hand_position_Y best32.	
		Right_Hand_position_Z best32.	Head_pitch best32.	Head_Yaw best32.	Head_Roll best32.;
    input @;
	if eov then input;
	input 	Participant_ID 	Dominant_Hand 	Player_Height 	Trial_Count	 Ambient_light	 Debris 
		Hallway_Length 	Background		Ethnicity 	Gender 	Weapon  	Spawn_Point 	Distance_From_Player 
		Target_Height 		Height_Difference  Prefade_Time 	Shadow_Fade_Time 	Reaction 	Reaction_Time 	
		Miliseconds 	Left_hand_pitch 	Left_hand_Yaw 	Left_hand_Roll 	Left_hand_Trigger_Press__ 	Left_hand_Grip_Press__ 	
		Left_Hand_position_X 	Left_Hand_position_Y 	Left_Hand_position_Z 	Right_Hand_pitch 	Right_Hand_Yaw	
		Right_Hand_Roll 	Right_Hand_Trigger_Press__ 	Right_Hand_Grip_Press__	 Right_Hand_position_X 	Right_Hand_position_Y 	
		Right_Hand_position_Z 	Head_pitch 	Head_Yaw 	Head_Roll ;
	subjpath = fname;
	eov=0;
    run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Apr 2024 19:46:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Error-Setting-many-datasets-where-same-variable-is-char-and-num/m-p/924190#M41454</guid>
      <dc:creator>davidsmarch1</dc:creator>
      <dc:date>2024-04-12T19:46:47Z</dc:date>
    </item>
    <item>
      <title>Re: Error Setting many datasets where same variable is char and num</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Error-Setting-many-datasets-where-same-variable-is-char-and-num/m-p/924191#M41455</link>
      <description>&lt;P&gt;I doubt that will work since you did not include the EOV= option on the INFILE statement.&lt;/P&gt;
&lt;P&gt;But you don't need it since you did include the FILENAME= option.&lt;/P&gt;
&lt;P&gt;So replace this line:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if eov then input;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;With&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if fname ne lag(fname) then input;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And remove this line:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;eov=0;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also not sure why you have the INFORMAT statement.&amp;nbsp; None of the variables listed require any special informats to be read properly. The informats you are attaching are what will be used anyway (BEST is really the name of a FORMAT and using it as an INFORMAT name will just result in the normal numeric infomat being used).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It would be much clearer to have a LENGTH (or ATTRIB) statement to directly set the variable type and length instead of forcing SAS to guess what type and length to define them as based on information available at the time they are first used in some other statement (in this case the INFORMAT statement).&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2024 20:01:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Error-Setting-many-datasets-where-same-variable-is-char-and-num/m-p/924191#M41455</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-04-12T20:01:08Z</dc:date>
    </item>
    <item>
      <title>Re: Error Setting many datasets where same variable is char and num</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Error-Setting-many-datasets-where-same-variable-is-char-and-num/m-p/924201#M41456</link>
      <description>&lt;P&gt;A minor point that may save some typing, when you have multiple variables with the same INFORMAT (or format) you can list all of the variables and only type the Informat (or format) name one time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2024 21:07:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Error-Setting-many-datasets-where-same-variable-is-char-and-num/m-p/924201#M41456</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-04-12T21:07:03Z</dc:date>
    </item>
    <item>
      <title>Re: Error Setting many datasets where same variable is char and num</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Error-Setting-many-datasets-where-same-variable-is-char-and-num/m-p/924291#M41461</link>
      <description>&lt;P&gt;This currently works and may address some of your suggestions:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data combined;
	LENGTH fname $200 Dominant_Hand $10 Background	$29	Ethnicity $5 Gender $4	Weapon $15 Spawn_Point $3 Reaction $15	Reaction_Time $5;
    infile 'M:\FPST-VR Pilot Testing\TestLogs Data Collection\*.csv' delimiter = ',' dsd truncover filename=fname;
	informat 	Participant_ID best32. Player_Height Trial_Count Ambient_light  Debris 
		Hallway_Length Distance_From_Player Target_Height Height_Difference Prefade_Time 	
		Shadow_Fade_Time Miliseconds Left_hand_pitch Left_hand_Yaw Left_hand_Roll 	
		Left_hand_Trigger_Press__ Left_hand_Grip_Press__  Left_Hand_position_X Left_Hand_position_Y 	
		Left_Hand_position_Z Right_Hand_pitch Right_Hand_Yaw Right_Hand_Roll 	
		Right_Hand_Trigger_Press__ Right_Hand_Grip_Press__	Right_Hand_position_X Right_Hand_position_Y 	
		Right_Hand_position_Z Head_pitch Head_Yaw Head_Roll;
    input @;
	if fname ne lag(fname) then input;
	input 	Participant_ID 	Dominant_Hand 	Player_Height 	Trial_Count	 Ambient_light	 Debris 
		Hallway_Length 	Background		Ethnicity 	Gender 	Weapon  	Spawn_Point 	Distance_From_Player 
		Target_Height 		Height_Difference  Prefade_Time 	Shadow_Fade_Time 	Reaction 	Reaction_Time 	
		Miliseconds 	Left_hand_pitch 	Left_hand_Yaw 	Left_hand_Roll 	Left_hand_Trigger_Press__ 	Left_hand_Grip_Press__ 	
		Left_Hand_position_X 	Left_Hand_position_Y 	Left_Hand_position_Z 	Right_Hand_pitch 	Right_Hand_Yaw	
		Right_Hand_Roll 	Right_Hand_Trigger_Press__ 	Right_Hand_Grip_Press__	 Right_Hand_position_X 	Right_Hand_position_Y 	
		Right_Hand_position_Z 	Head_pitch 	Head_Yaw 	Head_Roll ;
	subjpath = fname;
    run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Can you explain what the line "input&amp;nbsp;@" is doing?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Apr 2024 19:39:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Error-Setting-many-datasets-where-same-variable-is-char-and-num/m-p/924291#M41461</guid>
      <dc:creator>davidsmarch1</dc:creator>
      <dc:date>2024-04-14T19:39:12Z</dc:date>
    </item>
    <item>
      <title>Re: Error Setting many datasets where same variable is char and num</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Error-Setting-many-datasets-where-same-variable-is-char-and-num/m-p/924296#M41463</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/360861"&gt;@davidsmarch1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;This currently works and may address some of your suggestions:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You want to read multiple .csv with a single data step where you need to skip (not read) the header line of each of these .csv.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;infile 'M:\FPST-VR Pilot Testing\TestLogs Data Collection\*.csv' delimiter = ',' dsd truncover FILENAME=FNAME;&lt;BR /&gt;.....&lt;BR /&gt;if&amp;nbsp;fname&amp;nbsp;ne&amp;nbsp;lag(fname)....&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;FNAME contains the name of the source file that currently gets processed. If the name from the previous iteration of the data step is different - lag(fname) - then you are currently reading the first line of a new .csv which is the header line that you want to skip. That's the case where IF FNAME NE LAG(FNAME) becomes true.&lt;/P&gt;
&lt;P&gt;Each input statement moves the cursor to the next line of source text file unless you use the&amp;nbsp;@argument. That's fully documented for the&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/n0oaql83drile0n141pdacojq97s.htm" target="_self"&gt;INPUT Statement&lt;/A&gt; .&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1713140222240.png" style="width: 1095px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/95538iFB29C906F4F4E938/image-dimensions/1095x52?v=v2" width="1095" height="52" role="button" title="Patrick_0-1713140222240.png" alt="Patrick_0-1713140222240.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;You need &lt;EM&gt;input&amp;nbsp;&lt;/EM&gt;@;&amp;nbsp;&amp;nbsp; to read the next line to populate FNAME with the current name so you can compare it to the name of the previous line. But you need to keep the pointer on the current line so you can actually read this line into SAS variables in case it's not the header line.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it is the header line then you issue another input statement so the pointer moves to the next line where you've got data.&lt;/P&gt;
&lt;PRE&gt;if fname ne lag(fname) then input;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;...but: Above logic will fail should you have a source .csv that only contains a header line without any data. To circumvent such an issue you could instead code as below:&lt;/P&gt;
&lt;PRE&gt;input @;
if fname ne lag(fname) then RETURN;
input Participant_ID best32. ......&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also strongly suggest to use INFORMATS when reading source strings into SAS variables. Informats instruct SAS how to map a source string into a SAS variable.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;attrib .... dominant_hand length=$10 INFORMAT=$10.  ...and so on....&lt;/PRE&gt;
&lt;P&gt;...or alternatively use the informat directly within the input statement.&lt;/P&gt;
&lt;PRE&gt;input ..... dominant_hand :$10.  ....&lt;/PRE&gt;
&lt;P&gt;...and if there are a lot of variables and you're lazy then use the EG/Studio import wizard or Proc Import for one .csv and then copy/paste the generated data step code (with Proc Import from the SAS log) and amend it to what will work for all .csv's.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Apr 2024 01:33:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Error-Setting-many-datasets-where-same-variable-is-char-and-num/m-p/924296#M41463</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-04-15T01:33:55Z</dc:date>
    </item>
    <item>
      <title>Re: Error Setting many datasets where same variable is char and num</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Error-Setting-many-datasets-where-same-variable-is-char-and-num/m-p/924304#M41465</link>
      <description>&lt;P&gt;I usually use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;infile .... filename=fname;
input @;
if fname ne lag(fname) then delete;
input ....&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The will handle both empty files and files with only one line.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Apr 2024 03:25:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Error-Setting-many-datasets-where-same-variable-is-char-and-num/m-p/924304#M41465</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-04-15T03:25:07Z</dc:date>
    </item>
    <item>
      <title>Re: Error Setting many datasets where same variable is char and num</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Error-Setting-many-datasets-where-same-variable-is-char-and-num/m-p/924309#M41467</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/360861"&gt;@davidsmarch1&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;rightfully flagged: Don't use RETURN but DELETE to always ensure the desired result.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using RETURN will only work if you also add statement OUTPUT before the run statement.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Apr 2024 04:49:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Error-Setting-many-datasets-where-same-variable-is-char-and-num/m-p/924309#M41467</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-04-15T04:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: Error Setting many datasets where same variable is char and num</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Error-Setting-many-datasets-where-same-variable-is-char-and-num/m-p/924350#M41474</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/360861"&gt;@davidsmarch1&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;rightfully flagged: Don't use RETURN but DELETE to always ensure the desired result.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using RETURN will only work if you also add statement OUTPUT before the run statement.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Actually RETURN or DELETE will have the same effect as they will both end the current iteration of the data step.&amp;nbsp; I think you meant don't use INPUT as that will then allow the iteration to continue to the rest of the code statements.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Apr 2024 12:30:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Error-Setting-many-datasets-where-same-variable-is-char-and-num/m-p/924350#M41474</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-04-15T12:30:46Z</dc:date>
    </item>
  </channel>
</rss>

